本文整理汇总了C++中mutex::scoped_lock::mutex方法的典型用法代码示例。如果您正苦于以下问题:C++ scoped_lock::mutex方法的具体用法?C++ scoped_lock::mutex怎么用?C++ scoped_lock::mutex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutex::scoped_lock
的用法示例。
在下文中一共展示了scoped_lock::mutex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wait_for
void condition_variable::wait_for(mutex::scoped_lock& l, time_duration rel_time)
{
TORRENT_ASSERT(l.locked());
struct timeval tv;
struct timespec ts;
gettimeofday(&tv, NULL);
boost::uint64_t microseconds = tv.tv_usec + total_microseconds(rel_time) % 1000000;
ts.tv_nsec = (microseconds % 1000000) * 1000;
ts.tv_sec = tv.tv_sec + total_seconds(rel_time) + microseconds / 1000000;
// wow, this is quite a hack
pthread_cond_timedwait(&m_cond, (::pthread_mutex_t*)&l.mutex(), &ts);
}
示例2: wait
void condition_variable::wait(mutex::scoped_lock& l)
{
TORRENT_ASSERT(l.locked());
// wow, this is quite a hack
pthread_cond_wait(&m_cond, (::pthread_mutex_t*)&l.mutex());
}
示例3: wait
void condition_variable::wait(mutex::scoped_lock& l)
{
TORRENT_ASSERT(l.locked());
// wow, this is quite a hack
pthread_cond_wait(&m_cond, reinterpret_cast<pthread_mutex_t*>(&l.mutex()));
}