本文整理汇总了C++中boost::fibers::condition_variable_any::notify_one方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable_any::notify_one方法的具体用法?C++ condition_variable_any::notify_one怎么用?C++ condition_variable_any::notify_one使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::fibers::condition_variable_any
的用法示例。
在下文中一共展示了condition_variable_any::notify_one方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fn1
void fn1( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) {
m.lock();
BOOST_CHECK(test2 == 0);
test1 = 1;
cv.notify_one();
while (test2 == 0) {
cv.wait(m);
}
BOOST_CHECK(test2 != 0);
m.unlock();
}
示例2: fn5
void fn5( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) {
m.lock();
BOOST_CHECK(test2 == 0);
test1 = 1;
cv.notify_one();
std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now();
int count=0;
cv.wait_for(m, ms(250), Pred(test2));
count++;
std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
if (runs == 0) {
BOOST_CHECK(t1 - t0 < ms(250+1000));
BOOST_CHECK(test2 != 0);
} else {
BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+2));
BOOST_CHECK(test2 == 0);
}
++runs;
m.unlock();
}
示例3: fn3
void fn3( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) {
m.lock();
BOOST_CHECK(test2 == 0);
test1 = 1;
cv.notify_one();
std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point t = t0 + ms(250);
bool r = cv.wait_until(m, t, Pred(test2));
std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
if (runs == 0) {
BOOST_CHECK(t1 - t0 < ms(250));
BOOST_CHECK(test2 != 0);
BOOST_CHECK(r);
} else {
BOOST_CHECK(t1 - t0 - ms(250) < ms(250+2));
BOOST_CHECK(test2 == 0);
BOOST_CHECK(!r);
}
++runs;
m.unlock();
}
示例4: fn2
void fn2( boost::fibers::mutex & m, boost::fibers::condition_variable_any & cv) {
m.lock();
BOOST_CHECK(test2 == 0);
test1 = 1;
cv.notify_one();
std::chrono::system_clock::time_point t0 = std::chrono::system_clock::now();
std::chrono::system_clock::time_point t = t0 + ms(250);
int count=0;
while (test2 == 0 && cv.wait_until(m, t) == boost::fibers::cv_status::no_timeout)
count++;
std::chrono::system_clock::time_point t1 = std::chrono::system_clock::now();
if (runs == 0) {
BOOST_CHECK(t1 - t0 < ms(250));
BOOST_CHECK(test2 != 0);
} else {
BOOST_CHECK(t1 - t0 - ms(250) < ms(count*250+5+1000));
BOOST_CHECK(test2 == 0);
}
++runs;
m.unlock();
}
示例5: notify_one_fn
void notify_one_fn( boost::fibers::condition_variable_any & cond) {
cond.notify_one();
}