summaryrefslogtreecommitdiffstats
path: root/libcxx/test/thread
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-11-23 20:55:56 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-11-23 20:55:56 +0000
commitb32f147bbf97a6c90178baad3b588004c7e8bcaa (patch)
tree78a82832d72dbe83dc5cf30511b68af19f111b0d /libcxx/test/thread
parentfedfe3b69c1a5c31806a8b356ca57bd72674ca3c (diff)
downloadbcm5719-llvm-b32f147bbf97a6c90178baad3b588004c7e8bcaa.tar.gz
bcm5719-llvm-b32f147bbf97a6c90178baad3b588004c7e8bcaa.zip
Update testsuite strucuture to latest draft
llvm-svn: 120058
Diffstat (limited to 'libcxx/test/thread')
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp23
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp22
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp21
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp48
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp50
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp65
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp65
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp23
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp22
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp21
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp50
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp52
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp67
-rw-r--r--libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp67
15 files changed, 0 insertions, 608 deletions
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp
deleted file mode 100644
index b58f5c55b64..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/nothing_to_do.pass.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-int main()
-{
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
deleted file mode 100644
index 58006833eca..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// timed_mutex& operator=(const timed_mutex&) = delete;
-
-#include <mutex>
-
-int main()
-{
- std::timed_mutex m0;
- std::timed_mutex m1;
- m1 = m0;
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
deleted file mode 100644
index 61ba31d8648..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// timed_mutex(const timed_mutex&) = delete;
-
-#include <mutex>
-
-int main()
-{
- std::timed_mutex m0;
- std::timed_mutex m1(m0);
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
deleted file mode 100644
index 5956540e85c..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// timed_mutex();
-
-#include <mutex>
-
-int main()
-{
- std::timed_mutex m;
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
deleted file mode 100644
index be34e6db9a7..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// void lock();
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-#include <iostream>
-
-std::timed_mutex m;
-
-typedef std::chrono::system_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-void f()
-{
- time_point t0 = Clock::now();
- m.lock();
- time_point t1 = Clock::now();
- m.unlock();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(2500000)); // within 2.5ms
-}
-
-int main()
-{
- m.lock();
- std::thread t(f);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
deleted file mode 100644
index 41ddbbcf54a..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// bool try_lock();
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-std::timed_mutex m;
-
-typedef std::chrono::system_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-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 < ns(50000000)); // within 50ms
-}
-
-int main()
-{
- m.lock();
- std::thread t(f);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
deleted file mode 100644
index 1253659e211..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// template <class Rep, class Period>
-// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-std::timed_mutex m;
-
-typedef std::chrono::steady_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-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 < ns(5000000)); // within 5ms
-}
-
-void f2()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_for(ms(250)) == false);
- time_point t1 = Clock::now();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(5000000)); // within 5ms
-}
-
-int main()
-{
- {
- m.lock();
- std::thread t(f1);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
- }
- {
- m.lock();
- std::thread t(f2);
- std::this_thread::sleep_for(ms(300));
- m.unlock();
- t.join();
- }
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
deleted file mode 100644
index ac70d4a98e6..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class timed_mutex;
-
-// template <class Clock, class Duration>
-// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-std::timed_mutex m;
-
-typedef std::chrono::steady_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-void f1()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_until(Clock::now() + ms(300)) == true);
- time_point t1 = Clock::now();
- m.unlock();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(5000000)); // within 5ms
-}
-
-void f2()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_until(Clock::now() + ms(250)) == false);
- time_point t1 = Clock::now();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(5000000)); // within 5ms
-}
-
-int main()
-{
- {
- m.lock();
- std::thread t(f1);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
- }
- {
- m.lock();
- std::thread t(f2);
- std::this_thread::sleep_for(ms(300));
- m.unlock();
- t.join();
- }
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
deleted file mode 100644
index ae84be838d6..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
-
-#include <mutex>
-
-int main()
-{
- std::recursive_timed_mutex m0;
- std::recursive_timed_mutex m1;
- m1 = m0;
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
deleted file mode 100644
index 487d6a8c269..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// recursive_timed_mutex(const recursive_timed_mutex&) = delete;
-
-#include <mutex>
-
-int main()
-{
- std::recursive_timed_mutex m0;
- std::recursive_timed_mutex m1(m0);
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
deleted file mode 100644
index a4c5110e48c..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// recursive_timed_mutex();
-
-#include <mutex>
-
-int main()
-{
- std::recursive_timed_mutex m;
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
deleted file mode 100644
index b00fa46e37e..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// void lock();
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-#include <iostream>
-
-std::recursive_timed_mutex m;
-
-typedef std::chrono::system_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-void f()
-{
- time_point t0 = Clock::now();
- m.lock();
- time_point t1 = Clock::now();
- m.lock();
- m.unlock();
- m.unlock();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(2500000)); // within 2.5ms
-}
-
-int main()
-{
- m.lock();
- std::thread t(f);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
deleted file mode 100644
index fe5ef80a406..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// bool try_lock();
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-std::recursive_timed_mutex m;
-
-typedef std::chrono::system_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-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();
- assert(m.try_lock());
- m.unlock();
- m.unlock();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(50000000)); // within 50ms
-}
-
-int main()
-{
- m.lock();
- std::thread t(f);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
deleted file mode 100644
index 972fc637f04..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// template <class Rep, class Period>
-// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-std::recursive_timed_mutex m;
-
-typedef std::chrono::steady_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-void f1()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_for(ms(300)) == true);
- time_point t1 = Clock::now();
- assert(m.try_lock());
- m.unlock();
- m.unlock();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(50000000)); // within 50ms
-}
-
-void f2()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_for(ms(250)) == false);
- time_point t1 = Clock::now();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(50000000)); // within 50ms
-}
-
-int main()
-{
- {
- m.lock();
- std::thread t(f1);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
- }
- {
- m.lock();
- std::thread t(f2);
- std::this_thread::sleep_for(ms(300));
- m.unlock();
- t.join();
- }
-}
diff --git a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp b/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
deleted file mode 100644
index bfda9edced3..00000000000
--- a/libcxx/test/thread/thread.mutex/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <mutex>
-
-// class recursive_timed_mutex;
-
-// template <class Clock, class Duration>
-// bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
-
-#include <mutex>
-#include <thread>
-#include <cstdlib>
-#include <cassert>
-
-std::recursive_timed_mutex m;
-
-typedef std::chrono::steady_clock Clock;
-typedef Clock::time_point time_point;
-typedef Clock::duration duration;
-typedef std::chrono::milliseconds ms;
-typedef std::chrono::nanoseconds ns;
-
-void f1()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_until(Clock::now() + ms(300)) == true);
- time_point t1 = Clock::now();
- assert(m.try_lock());
- m.unlock();
- m.unlock();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(5000000)); // within 5ms
-}
-
-void f2()
-{
- time_point t0 = Clock::now();
- assert(m.try_lock_until(Clock::now() + ms(250)) == false);
- time_point t1 = Clock::now();
- ns d = t1 - t0 - ms(250);
- assert(d < ns(5000000)); // within 5ms
-}
-
-int main()
-{
- {
- m.lock();
- std::thread t(f1);
- std::this_thread::sleep_for(ms(250));
- m.unlock();
- t.join();
- }
- {
- m.lock();
- std::thread t(f2);
- std::this_thread::sleep_for(ms(300));
- m.unlock();
- t.join();
- }
-}
OpenPOWER on IntegriCloud