From eda1a337de6ec683d12df0e7bc64648d61bc7049 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 20 Jul 2013 14:18:22 -0700 Subject: [PATCH] Add more tests Signed-off-by: Leonardo de Moura --- src/tests/util/interrupt.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/tests/util/interrupt.cpp b/src/tests/util/interrupt.cpp index cfa8577f3..e1c674d8b 100644 --- a/src/tests/util/interrupt.cpp +++ b/src/tests/util/interrupt.cpp @@ -39,7 +39,35 @@ static void tst1() { t2.join(); } +class A { +public: + unsigned m_x; + A():m_x(0) { std::cout << "created...\n"; } + ~A() { std::cout << "deleted: " << m_x << "\n"; } +}; + +static thread_local A g_a; + +static void mka(unsigned x) { + std::cout << "starting mka " << x << "\n"; + g_a.m_x = x; +} + +static void tst2() { + { + std::thread t1([](){ mka(1); }); + t1.join(); + } + std::thread t2([](){ mka(2); + std::chrono::milliseconds dura(200); + std::this_thread::sleep_for(dura); + }); + std::thread t3([](){ mka(3); }); + t2.join(); t3.join(); +} + int main() { tst1(); + tst2(); return 0; }