diff --git a/doc/Changelog.md b/doc/Changelog.md index 333f2234e4..a5e1f2b7b6 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -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): diff --git a/eq/base.h b/eq/base.h index 0899b2f23e..dc056a1fc9 100644 --- a/eq/base.h +++ b/eq/base.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2010-2013, Stefan Eilemann +/* Copyright (c) 2010-2015, Stefan Eilemann * * 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 @@ -96,6 +96,7 @@ #include #include #include +#include #include #include #include diff --git a/eq/commandQueue.cpp b/eq/commandQueue.cpp index 44ae597ac0..2a1fc3fbc4 100644 --- a/eq/commandQueue.cpp +++ b/eq/commandQueue.cpp @@ -1,6 +1,6 @@ -/* Copyright (c) 2007-2013, Stefan Eilemann - * 2012, Daniel Nachbaur +/* Copyright (c) 2007-2015, Stefan Eilemann + * Daniel Nachbaur * * 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 @@ -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(); } }