Request<?> item = super.take(); if (item == mStopRequest) { mStopEvent.release(); return take(); } return item;
// TODO: this isn't really "until empty" it's "until next call to take() after empty" add(mStopRequest); if (!mStopEvent.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS)) { throw new TimeoutException(); }