aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-16 21:04:22 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-16 21:04:22 +0000
commit4befb1f96d641a958548654b2c3b674f0ce8404c (patch)
tree664480204c546e55b123766a30e6fcf022c5486e /packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp
parentf1d04915a666728c241bedb36bd99aafee3ea444 (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp
index 6a0ea4e0d1191..42a07f353030d 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/num_threads/main.cpp
@@ -1,15 +1,19 @@
+#include "pseudo_barrier.h"
#include <condition_variable>
#include <mutex>
#include <thread>
+#include <vector>
std::mutex mutex;
std::condition_variable cond;
+pseudo_barrier_t thread3_barrier;
void *
thread3(void *input)
{
- std::unique_lock<std::mutex> lock(mutex);
- cond.notify_all(); // Set break point at this line.
+ pseudo_barrier_wait(thread3_barrier);
+ std::unique_lock<std::mutex> lock(mutex); // Set thread3 break point on lock at this line.
+ cond.notify_all(); // Set thread3 break point on notify_all at this line.
return NULL;
}
@@ -17,7 +21,7 @@ void *
thread2(void *input)
{
std::unique_lock<std::mutex> lock(mutex);
- cond.notify_all();
+ cond.notify_all(); // release main thread
cond.wait(lock);
return NULL;
}
@@ -36,15 +40,23 @@ int main()
std::unique_lock<std::mutex> lock(mutex);
std::thread thread_1(thread1, nullptr);
- cond.wait(lock);
+ cond.wait(lock); // wait for thread2
- std::thread thread_3(thread3, nullptr);
- cond.wait(lock);
+ pseudo_barrier_init(thread3_barrier, 10);
+
+ std::vector<std::thread> thread_3s;
+ for (int i = 0; i < 10; i++) {
+ thread_3s.push_back(std::thread(thread3, nullptr));
+ }
+
+ cond.wait(lock); // wait for thread_3s
lock.unlock();
thread_1.join();
- thread_3.join();
+ for (auto &t : thread_3s){
+ t.join();
+ }
return 0;
}