コード例 #1
0
ファイル: condition_variable.hpp プロジェクト: kaidokert/weos
    cv_status::cv_status wait_for(unique_lock<mutex>& lock,
                                  const chrono::duration<RepT, PeriodT>& d)
    {
        // First enqueue ourselves in the list of waiters.
        WaitingThread w;
        enqueue(w);

        // We can only unlock the lock when we are sure that a signal will
        // reach our thread.
        detail::lock_releaser<unique_lock<mutex> > releaser(lock);
        // Wait until we receive a signal, then re-lock the lock.
        bool gotSignal = w.signal.try_wait_for(d);

        // If we have received a signal, we have _always_ been dequeued.
        // If the other case, we might have been dequeued or might have
        // been not. In that case, we have to check the dequeued flag.
        if (!gotSignal)
        {
            maybeDequeue(w);
            return cv_status::timeout;
        }

        return cv_status::no_timeout;
    }
コード例 #2
0
ファイル: AsyncIO.cpp プロジェクト: JasonCC/folly
void AsyncIOQueue::onCompleted(AsyncIOOp* op) {
  maybeDequeue();
}
コード例 #3
0
ファイル: AsyncIO.cpp プロジェクト: JasonCC/folly
void AsyncIOQueue::submit(OpFactory op) {
  queue_.push_back(op);
  maybeDequeue();
}