diff --git a/system/jlib/jqueue.tpp b/system/jlib/jqueue.tpp index 841b0396f20..44ed3a88115 100644 --- a/system/jlib/jqueue.tpp +++ b/system/jlib/jqueue.tpp @@ -242,6 +242,7 @@ template class SafeQueueOf : private QueueOf { typedef SafeQueueOf SELF; + typedef QueueOf PARENT; protected: mutable CriticalSection crit; inline void unsafeenqueue(BASE *e) { QueueOf::enqueue(e); } @@ -267,6 +268,7 @@ public: void dequeue(BASE *e) { CriticalBlock b(crit); return QueueOf::dequeue(e); } inline unsigned ordinality() const { return QueueOf::ordinality(); } void set(unsigned idx, BASE *e) { CriticalBlock b(crit); return QueueOf::set(idx, e); } + using PARENT::ensure; }; @@ -535,6 +537,8 @@ public: } }; +//A lighter-weight limited thread queue which does not allow timeouts. +//Linux futexes mean that semaphores now perform very well... template class ReallySimpleInterThreadQueueOf : protected SafeQueueOf { @@ -587,14 +591,15 @@ public: { limit = num; space.reinit(limit); + PARENT::ensure(limit); } - void stop() // stops all waiting operations + void stop(unsigned maxReaders = 0, unsigned maxWriters = 0) // stops all waiting operations { - //Assume maxreaders < limit, maxwriters < limit + //Assume maxreaders < limit, maxwriters < limit if not provided stopped = true; - avail.signal(limit); - space.signal(limit); + avail.signal(maxReaders ? maxReaders : limit); + space.signal(maxWriters ? maxWriters : limit); } BASE *dequeueNow()