本文整理汇总了C++中Cond::timed_wait方法的典型用法代码示例。如果您正苦于以下问题:C++ Cond::timed_wait方法的具体用法?C++ Cond::timed_wait怎么用?C++ Cond::timed_wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cond
的用法示例。
在下文中一共展示了Cond::timed_wait方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool
KRT2Device::Send(const uint8_t *msg, unsigned msg_size,
OperationEnvironment &env)
{
//! Number of tries to send a message
unsigned retries = NR_RETRIES;
assert(msg_size > 0);
do {
response_mutex.Lock();
response = NO_RSP;
response_mutex.Unlock();
// Send the message
if (!port.FullWrite(msg, msg_size, env, CMD_TIMEOUT))
return false;
// Wait for the response
response_mutex.Lock();
rx_cond.timed_wait(response_mutex, CMD_TIMEOUT);
auto _response = response;
response_mutex.Unlock();
if (_response == ACK)
// ACK received, finish
return true;
// No ACK received, retry
retries--;
} while (retries);
return false;
}
示例2: Wait
const_iterator Wait(const K &key, OperationEnvironment &env,
TimeoutClock timeout) {
while (true) {
auto i = map.find(key);
if (i != map.end() && !i->second.old)
return const_iterator(i);
if (env.IsCancelled())
return end();
int remaining = timeout.GetRemainingSigned();
if (remaining <= 0)
return end();
cond.timed_wait(*this, remaining);
}
}
示例3: wait
bool CondTime::wait(Mutex& mutex, Cond& cond)
{
return cond.timed_wait(mutex,timepoint);
}