void condition_variable::wait(unique_lock<mutex>& lock) noexcept { #ifdef NOEXCEPTIONS lock.owns_lock(); #else if (!lock.owns_lock()) { throw std::system_error( std::make_error_code(std::errc::operation_not_permitted), "Mutex not locked."); } #endif priority_queue_node_t n; n.priority = sched_active_thread->priority; n.data = sched_active_pid; n.next = NULL; // the signaling thread may not hold the mutex, the queue is not thread safe unsigned old_state = disableIRQ(); priority_queue_add(&m_queue, &n); restoreIRQ(old_state); mutex_unlock_and_sleep(lock.mutex()->native_handle()); if (n.data != -1u) { // on signaling n.data is set to -1u // if it isn't set, then the wakeup is either spurious or a timer wakeup old_state = disableIRQ(); priority_queue_remove(&m_queue, &n); restoreIRQ(old_state); } mutex_lock(lock.mutex()->native_handle()); }
typename enable_if< is_condition_variable_compatible< Mutex >, void >::type wait(unique_lock< Mutex >& lock, Predicate pred) { BOOST_ASSERT(lock.owns_lock()); pthread_mutex_t* const mtx = lock.mutex()->native_handle(); while (!pred()) this->priv_wait(mtx); }
//! Initializing constructor scoped_thread_id(unique_lock< frontend_mutex_type >& l, condition_variable_any& cond, thread::id& tid, bool volatile& sr) : m_Mutex(*l.mutex()), m_Cond(cond), m_ThreadID(tid), m_StopRequested(sr) { unique_lock< frontend_mutex_type > lock(move(l)); if (m_ThreadID != thread::id()) BOOST_LOG_THROW_DESCR(unexpected_call, "Asynchronous sink frontend already runs a record feeding thread"); m_ThreadID = this_thread::get_id(); }
void wait( unique_lock< mutex > & lk, Pred pred) { if ( ! lk) throw lock_error(); while ( ! pred() ) wait( * lk.mutex() ); }
sync::cv_status priv_timed_wait(unique_lock< Mutex >& lock, sync::detail::system_time_point const& t) { int const res = sync::detail::posix::pthread_cond_timedwait(&m_cond, lock.mutex()->native_handle(), &t.get()); if (res == ETIMEDOUT) return sync::cv_status::timeout; else if (res != 0) BOOST_SYNC_DETAIL_THROW(wait_error, (res)("boost::sync::condition_variable timedwait failed in pthread_cond_timedwait")); return sync::cv_status::no_timeout; }
void condition_variable::wait(unique_lock<mutex>& lk) { if (!lk.owns_lock()) __throw_system_error(EPERM, "condition_variable::wait: mutex not locked"); int ec = pthread_cond_wait(&__cv_, lk.mutex()->native_handle()); if (ec) __throw_system_error(ec, "condition_variable wait failed"); }
inline bool condition_variable::timed_wait(unique_lock<mutex>& m,boost::system_time const& wait_until) { detail::interruption_checker check_for_interruption(&cond); struct timespec const timeout=detail::get_timespec(wait_until); int const cond_res=pthread_cond_timedwait(&cond,m.mutex()->native_handle(),&timeout); if(cond_res==ETIMEDOUT) { return false; } BOOST_ASSERT(!cond_res); return true; }
void condition_variable::wait(unique_lock<mutex> &m) { details::event ev; { booster::unique_lock<booster::mutex> g(d->lock); m.mutex()->unlock(); if(d->first == 0) { d->first = d->last = &ev; } else { d->last->next = &ev; d->last = &ev; } } ev.wait(); m.mutex()->lock(); }
void condition_variable::__do_timed_wait(unique_lock<mutex>& lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) { using namespace chrono; if (!lk.owns_lock()) __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); nanoseconds d = tp.time_since_epoch(); timespec ts; seconds s = duration_cast<seconds>(d); ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count()); ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); if (ec != 0 && ec != ETIMEDOUT) __throw_system_error(ec, "condition_variable timed_wait failed"); }
void condition_variable::wait(unique_lock<mutex> &m) { pthread_cond_wait(&d->c,&(m.mutex()->d->m)); }
void wait( unique_lock< mutex > & lk) { if ( ! lk) throw lock_error(); wait( * lk.mutex() ); }
void condition_variable::wait(unique_lock<mutex> &m) { SleepConditionVariableCS(&d->c,&(m.mutex()->d->m),INFINITE); }
typename enable_if< is_condition_variable_compatible< Mutex >, void >::type wait(unique_lock< Mutex >& lock) { BOOST_ASSERT(lock.owns_lock()); this->priv_wait(lock.mutex()->native_handle()); }
inline void condition_variable::wait(unique_lock<mutex>& m) { detail::interruption_checker check_for_interruption(&cond); BOOST_VERIFY(!pthread_cond_wait(&cond,m.mutex()->native_handle())); }