CommonLibs: Allow NULLs to be retrieved from InterthreadQueue.
We need a way to stop InterthreadQueue blocking read to be able to shutdown a thread. The easiest way to do that is to push NULL to the queue, but the original implementation will just ignore that and continue blocking. After the change the blocking read() will exit with NULL result which is perfectly fine with us. Ideally we should change all methods of InterthreadQueue to return a status value to indicate normal exits, timeouts, etc. Right now the only way to indicate an error is returning NULL, which could be a valid operation.
This commit is contained in:
parent
b864694652
commit
69b6a6dfcd
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright 2008, 2011 Free Software Foundation, Inc.
|
||||
* Copyright 2013 Alexander Chemeris <Alexander.Chemeris@fairwaves.ru>
|
||||
*
|
||||
* This software is distributed under the terms of the GNU Affero Public License.
|
||||
* See the COPYING file in the main directory for details.
|
||||
|
@ -99,7 +100,7 @@ template <class T, class Fifo=PointerFIFO> class InterthreadQueue {
|
|||
{
|
||||
ScopedLock lock(mLock);
|
||||
T* retVal = (T*)mQ.get();
|
||||
while (retVal==NULL) {
|
||||
if (retVal==NULL) {
|
||||
mWriteSignal.wait(mLock);
|
||||
retVal = (T*)mQ.get();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue