1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This test verifies the correct handling of child thread exits.
15 pseudo_barrier_t g_barrier1;
16 pseudo_barrier_t g_barrier2;
17 pseudo_barrier_t g_barrier3;
22 // Synchronize with the main thread.
23 pseudo_barrier_wait(g_barrier1);
25 // Synchronize with the main thread and thread2.
26 pseudo_barrier_wait(g_barrier2);
29 return NULL; // Set second breakpoint here
35 // Synchronize with thread1 and the main thread.
36 pseudo_barrier_wait(g_barrier2);
38 // Synchronize with the main thread.
39 pseudo_barrier_wait(g_barrier3);
47 pseudo_barrier_init(g_barrier1, 2);
48 pseudo_barrier_init(g_barrier2, 3);
49 pseudo_barrier_init(g_barrier3, 2);
52 std::thread thread_1(thread1);
54 // Wait for thread1 to start.
55 pseudo_barrier_wait(g_barrier1);
57 // Create another thread.
58 std::thread thread_2(thread2); // Set first breakpoint here
60 // Wait for thread2 to start.
61 pseudo_barrier_wait(g_barrier2);
63 // Wait for the first thread to finish
66 // Synchronize with the remaining thread
67 pseudo_barrier_wait(g_barrier3); // Set third breakpoint here
69 // Wait for the second thread to finish
72 return 0; // Set fourth breakpoint here