本文整理汇总了C++中std::shared_timed_mutex::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_timed_mutex::unlock方法的具体用法?C++ shared_timed_mutex::unlock怎么用?C++ shared_timed_mutex::unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::shared_timed_mutex
的用法示例。
在下文中一共展示了shared_timed_mutex::unlock方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
#if _LIBCPP_STD_VER > 11
{
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f1));
std::this_thread::sleep_for(ms(250));
m.unlock();
for (auto& t : v)
t.join();
}
{
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f2));
std::this_thread::sleep_for(ms(300));
m.unlock();
for (auto& t : v)
t.join();
}
#endif // _LIBCPP_STD_VER > 11
}
示例2: main
int main(int, char**)
{
{
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f1));
std::this_thread::sleep_for(WaitTime);
m.unlock();
for (auto& t : v)
t.join();
}
{
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f2));
std::this_thread::sleep_for(WaitTime + Tolerance);
m.unlock();
for (auto& t : v)
t.join();
}
return 0;
}
示例3: main
int main()
{
{
m.lock();
std::thread t(f1);
std::this_thread::sleep_for(WaitTime);
m.unlock();
t.join();
}
{
m.lock();
std::thread t(f2);
std::this_thread::sleep_for(WaitTime + Tolerance);
m.unlock();
t.join();
}
}
示例4: f1
void f1()
{
time_point t0 = Clock::now();
assert(m.try_lock_until(Clock::now() + WaitTime + Tolerance) == true);
time_point t1 = Clock::now();
m.unlock();
ns d = t1 - t0 - WaitTime;
assert(d < Tolerance); // within tolerance
}
示例5: f
void f()
{
time_point t0 = Clock::now();
m.lock();
time_point t1 = Clock::now();
m.unlock();
ns d = t1 - t0 - ms(250);
assert(d < ms(50)); // within 50ms
}
示例6: f1
void f1()
{
time_point t0 = Clock::now();
assert(m.try_lock_for(ms(300)) == true);
time_point t1 = Clock::now();
m.unlock();
ns d = t1 - t0 - ms(250);
assert(d < ms(50)); // within 50ms
}
示例7: main
int main()
{
#if _LIBCPP_STD_VER > 11
m.lock();
std::thread t(f);
std::this_thread::sleep_for(ms(250));
m.unlock();
t.join();
#endif // _LIBCPP_STD_VER > 11
}
示例8: main
int main()
{
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f));
std::this_thread::sleep_for(ms(250));
m.unlock();
for (auto& t : v)
t.join();
}
示例9: f
void f()
{
time_point t0 = Clock::now();
assert(!m.try_lock());
assert(!m.try_lock());
assert(!m.try_lock());
while(!m.try_lock())
;
time_point t1 = Clock::now();
m.unlock();
ns d = t1 - t0 - ms(250);
assert(d < ms(200)); // within 200ms
}
示例10: main
int main()
{
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f));
std::this_thread::sleep_for(WaitTime);
m.unlock();
for (auto& t : v)
t.join();
m.lock_shared();
for (auto& t : v)
t = std::thread(g);
std::thread q(f);
std::this_thread::sleep_for(WaitTime);
m.unlock_shared();
for (auto& t : v)
t.join();
q.join();
}
示例11: main
int main()
{
#if _LIBCPP_STD_VER > 11
m.lock();
std::vector<std::thread> v;
for (int i = 0; i < 5; ++i)
v.push_back(std::thread(f));
std::this_thread::sleep_for(ms(250));
m.unlock();
for (auto& t : v)
t.join();
m.lock_shared();
for (auto& t : v)
t = std::thread(g);
std::thread q(f);
std::this_thread::sleep_for(ms(250));
m.unlock_shared();
for (auto& t : v)
t.join();
q.join();
#endif // _LIBCPP_STD_VER > 11
}