# A collection which `is_empty` method blocks until it's empty
class ReverseBlockingQueue[E]
super ConcurrentList[E]
# Used to block or signal on waiting threads
private var cond = new PthreadCond
# Adding the signal to release eventual waiting thread(s)
redef fun push(e) do
mutex.lock
real_collection.push(e)
mutex.unlock
end
# When the Queue is empty, signal any possible waiting thread
redef fun remove(e) do
mutex.lock
real_collection.remove(e)
if real_collection.is_empty then cond.signal
mutex.unlock
end
# Wait until the Queue is empty
redef fun is_empty do
mutex.lock
while not real_collection.is_empty do self.cond.wait(mutex)
mutex.unlock
return true
end
end
lib/pthreads/concurrent_collections.nit:520,1--549,3