Queue a new data, which may unblock a thread waiting for it.
552869
public void newDataReady(DataType data) {
		ArrayList<Runnable> list;
		synchronized (this) {
			if (end) throw new IllegalStateException("method endOfData already called, method newDataReady is not allowed anymore");
			waitingData.addLast(data);
			list = listeners;
			listeners = null;
		}
		if (list != null) {
			for (Runnable listener : list) listener.run();
		}
		// notify after listeners
		synchronized (this) {
			this.notify();
		}
	}
1043730
private static void wait(Object lock, int timeout)
  {
    try {
      lock.wait(timeout);
    }
    catch(InterruptedException unused) {
      Thread.currentThread().interrupt();
    }
  }
845966
def notifyPop(self, queue, length = 1):
        '''
        
        '''
        self.totalSize = self.totalSize - length
        ret1 = []
        ret2 = []
        if self.isWaited and self.canAppend():
            self.isWaited = False
            ret1.append(QueueCanWriteEvent(self))
        if self.isWaitEmpty and not self:
            self.isWaitEmpty = False
            ret2.append(QueueIsEmptyEvent(self))
        if self.parent is not None:
            pr = self.parent.notifyPop(self, length)
            ret1 += pr[0]
            ret2 += pr[1]
        newblocked =  not self.canPop()
        if newblocked != self.blocked:
            self.blocked = newblocked
            if self.parent is not None:
                self.parent.notifyBlock(self, newblocked)
        return (ret1, ret2)
700620
protected void processQueue() {
        try {
            QueueItem item = queue.take();
            client.addMultipleCounterDataPoints(item.tenantId, item.data);
        } catch (InterruptedException e) {
            // TODO better logging of this unlikely error
            e.printStackTrace();
            return;
        }
    }
442690
public void queue(final PoolWaitFuture<PoolableObject<V>> future) {
		if (future == null) return;
		waiting.add(future);
	}
574320
def add(self, value, timeout=None, force=False):
        
        with self.lock:
            if value is THREAD_STOP:
                # INSIDE THE lock SO THAT EXITING WILL RELEASE wait()
                self.queue.append(value)
                self.closed.go()
                return

            if not force:
                self._wait_for_queue_space(timeout=timeout)
            if self.closed and not self.allow_add_after_close:
                Log.error("Do not add to closed queue")
            else:
                if self.unique:
                    if value not in self.queue:
                        self.queue.append(value)
                else:
                    self.queue.append(value)
        return self
441251
def wait(self, till=None):
        
        waiter = Signal()
        if self.waiting:
            DEBUG and _Log.note("waiting with {{num}} others on {{name|quote}}", num=len(self.waiting), name=self.name, stack_depth=1)
            self.waiting.insert(0, waiter)
        else:
            DEBUG and _Log.note("waiting by self on {{name|quote}}", name=self.name)
            self.waiting = [waiter]

        try:
            self.lock.release()
            DEBUG and _Log.note("out of lock {{name|quote}}", name=self.name)
            (waiter | till).wait()
            if DEBUG:
                _Log.note("done minimum wait (for signal {{till|quote}})", till=till.name if till else "", name=self.name)
        except Exception as e:
            if not _Log:
                _late_import()
            _Log.warning("problem", cause=e)
        finally:
            self.lock.acquire()
            DEBUG and _Log.note("re-acquired lock {{name|quote}}", name=self.name)

        try:
            self.waiting.remove(waiter)
            DEBUG and _Log.note("removed own signal from {{name|quote}}", name=self.name)
        except Exception:
            pass

        return bool(waiter)
187868
protected void dataReady(FrameHeaderData headerData, PooledByteBuffer frameData) {
        if(anyAreSet(state, STATE_STREAM_BROKEN | STATE_CLOSED)) {
            frameData.close();
            return;
        }
        synchronized (lock) {
            boolean newData = pendingFrameData.isEmpty();
            this.pendingFrameData.add(new FrameData(headerData, frameData));
            if (newData) {
                if (waiters > 0) {
                    lock.notifyAll();
                }
            }
            waitingForFrame = false;
        }
        if (anyAreSet(state, STATE_READS_RESUMED)) {
            resumeReadsInternal(true);
        }
        if(headerData != null) {
            currentStreamSize += headerData.getFrameLength();
            if(maxStreamSize > 0 && currentStreamSize > maxStreamSize) {
                handleStreamTooLarge();
            }
        }
    }
1131521
def queue_call(self, delay, callback, *args, **kwds):
    """"""
    if delay is None:
      self.current.append((callback, args, kwds))
      return
    if delay < 1e9:
      when = delay + self.clock.now()
    else:
      # Times over a billion seconds are assumed to be absolute.
      when = delay
    self.insort_event_right((when, callback, args, kwds))
269287
function (data) {
            if (!ready) {
                return;
            }
            var i;
            if (data.all === true) {
                data.upto = numPages;
            }
            if (data.page) {
                this.queuePageToLoad(data.page - 1);
            } else if (data.upto) {
                for (i = 0; i < data.upto; ++i) {
                    this.queuePageToLoad(i);
                }
            }
        }
1089358
def wait(self):
        
        if self._go:
            return True

        with self.lock:
            if self._go:
                return True
            stopper = _allocate_lock()
            stopper.acquire()
            if not self.waiting_threads:
                self.waiting_threads = [stopper]
            else:
                self.waiting_threads.append(stopper)

        DEBUG and self._name and Log.note("wait for go {{name|quote}}", name=self.name)
        stopper.acquire()
        DEBUG and self._name and Log.note("GOing! {{name|quote}}", name=self.name)
        return True
721584
def _threaded(self, *args, **kwargs):
        """"""

        for target in self.targets:
            result = target(*args, **kwargs)
            self.queue.put(result)
709112
private static <T> ListenableFuture<T> submitAndAddQueueListener(
      ListeningExecutorService executorService, Callable<T> task,
      final BlockingQueue<Future<T>> queue) {
    final ListenableFuture<T> future = executorService.submit(task);
    future.addListener(new Runnable() {
      @Override public void run() {
        queue.add(future);
      }
    }, directExecutor());
    return future;
  }
512291
function doSomethingUninteresting(data) {
  // simulate latency
  var wait = randomWait(1000);
  return Promise.delay(wait).then(
    () => `It took me ${wait} milliseconds to notice you gave me ${data}.`
  );
}
731794
function(data, showStatus, callback) {
    if (showStatus===undefined) showStatus=true;

    /* Queue our data to write. If there was previous data and no callback to
    invoke on this data or the previous then just append data. This would happen
    if typing in the terminal for example. */
    if (!callback && writeData.length && !writeData[writeData.length-1].callback) {
      writeData[writeData.length-1].data += data;
    } else {
      writeData.push({data:data,callback:callback,showStatus:showStatus});
      /* if this is our first data, start sending now. Otherwise we're already
      busy sending and will pull data off writeData when ready */
      if (writeData.length==1)
        writeSerialWorker(true);
    }
  }
446430
private void blockingRefresh() {
        try {
            if (blockingRefreshLock
                    .tryLock(BLOCKING_REFRESH_MAX_WAIT_IN_SECONDS, TimeUnit.SECONDS)) {
                try {
                    // Return if successful refresh occurred while waiting for the lock
                    if (!shouldDoBlockingRefresh()) {
                        return;
                    } else {
                        // Otherwise do a synchronous refresh if the last lock holder was unable to
                        // refresh the value
                        refreshValue();
                        return;
                    }
                } finally {
                    blockingRefreshLock.unlock();
                }
            }
        } catch (InterruptedException ex) {
            handleInterruptedException("Interrupted waiting to refresh the value.", ex);
        }
        // Couldn't acquire the lock. Just try a synchronous refresh
        refreshValue();
    }
388309
def pop(non_block=false)
      handle_interrupt do
        @mutex.synchronize do
          while true
            if @que.empty?
              if non_block
                raise ThreadError, "queue empty"
              else
                begin
                  @num_waiting += 1
                  @cond.wait @mutex
                ensure
                  @num_waiting -= 1
                end
              end
            else
              return @que.shift
            end
          end
        end
      end
    end