Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Config::getNextEvent() with definite timeout #481

Merged
merged 1 commit into from
Aug 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Changelog {#Changelog}

# git master {#master}

* [481](https://github.com/Eyescale/Equalizer/pull/481):
Fix Config::getNextEvent() with definite timeout
* [467](https://github.com/Eyescale/Equalizer/issues/467):
Fix CPU load with idle Qt-based windows
* [479](https://github.com/Eyescale/Equalizer/pull/479):
Expand Down
3 changes: 2 additions & 1 deletion eq/base.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/* Copyright (c) 2010-2013, Stefan Eilemann <[email protected]>
/* Copyright (c) 2010-2015, Stefan Eilemann <[email protected]>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 2.1 as published
Expand Down Expand Up @@ -96,6 +96,7 @@
#include <eq/init.h>
#include <eq/layout.h>
#include <eq/log.h>
#include <eq/messagePump.h>
#include <eq/node.h>
#include <eq/nodeFactory.h>
#include <eq/observer.h>
Expand Down
46 changes: 27 additions & 19 deletions eq/commandQueue.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/* Copyright (c) 2007-2013, Stefan Eilemann <[email protected]>
* 2012, Daniel Nachbaur <[email protected]>
/* Copyright (c) 2007-2015, Stefan Eilemann <[email protected]>
* Daniel Nachbaur <[email protected]>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 2.1 as published
Expand Down Expand Up @@ -59,67 +59,75 @@ void CommandQueue::pushFront( const co::ICommand& command )

co::ICommand CommandQueue::pop( const uint32_t timeout )
{
int64_t start = -1;
const int64_t start = _clock.getTime64();
int64_t waitBegin = -1;
while( true )
{
if( _messagePump )
_messagePump->dispatchAll(); // non-blocking

// Poll for a command
if( !isEmpty() || timeout == 0 )
if( !isEmpty( ))
{
if( start > -1 )
_waitTime += ( _clock.getTime64() - start );
return co::CommandQueue::pop( timeout );
if( waitBegin > -1 )
_waitTime += ( _clock.getTime64() - waitBegin );
return co::CommandQueue::pop( 0 );
}

if( _messagePump )
{
if( start == -1 )
start = _clock.getTime64();
if( waitBegin == -1 )
waitBegin = _clock.getTime64();
_messagePump->dispatchOne( timeout ); // blocks - push sends wakeup
}
else
{
start = _clock.getTime64();
waitBegin = _clock.getTime64();
// blocking
const co::ICommand& command = co::CommandQueue::pop( timeout );
_waitTime += ( _clock.getTime64() - start );
_waitTime += ( _clock.getTime64() - waitBegin );
return command;
}

if( _clock.getTime64() - start > timeout )
return co::ICommand();
}
}

co::ICommands CommandQueue::popAll( const uint32_t timeout )
{
int64_t start = -1;
const int64_t start = _clock.getTime64();
int64_t waitBegin = -1;
while( true )
{
if( _messagePump )
_messagePump->dispatchAll(); // non-blocking

// Poll for commands
if( !isEmpty() || timeout == 0 )
if( !isEmpty( ))
{
if( start > -1 )
_waitTime += ( _clock.getTime64() - start );
if( waitBegin > -1 )
_waitTime += ( _clock.getTime64() - waitBegin );
return co::CommandQueue::popAll( 0 );
}

if( _messagePump )
{
if( start == -1 )
start = _clock.getTime64();
if( waitBegin == -1 )
waitBegin = _clock.getTime64();
_messagePump->dispatchOne( timeout ); // blocks - push sends wakeup
}
else
{
start = _clock.getTime64();
waitBegin = _clock.getTime64();
// blocking
const co::ICommands& commands = co::CommandQueue::popAll( timeout );
_waitTime += ( _clock.getTime64() - start );
_waitTime += ( _clock.getTime64() - waitBegin );
return commands;
}

if( _clock.getTime64() - start > timeout )
return co::ICommands();
}
}

Expand Down