]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | |
2 | // lw_thread_test.cpp | |
3 | // | |
4 | // Copyright 2018 Peter Dimov | |
5 | // Distributed under the Boost Software License, Version 1.0. | |
6 | ||
7 | #include <boost/detail/lightweight_thread.hpp> | |
8 | #include <boost/detail/lightweight_test.hpp> | |
9 | #include <boost/smart_ptr/detail/atomic_count.hpp> | |
10 | ||
11 | boost::detail::atomic_count count( 0 ); | |
12 | ||
13 | void f() | |
14 | { | |
15 | ++count; | |
16 | } | |
17 | ||
18 | int main() | |
19 | { | |
20 | int const N = 4; | |
92f5a8d4 | 21 | boost::detail::lw_thread_t th[ N ] = {}; |
11fdf7f2 TL |
22 | |
23 | for( int i = 0; i < N; ++i ) | |
24 | { | |
25 | boost::detail::lw_thread_create( th[ i ], f ); | |
26 | } | |
27 | ||
28 | for( int i = 0; i < N; ++i ) | |
29 | { | |
92f5a8d4 | 30 | boost::detail::lw_thread_join( th[ i ] ); |
11fdf7f2 TL |
31 | } |
32 | ||
33 | BOOST_TEST_EQ( count, N ); | |
34 | ||
35 | return boost::report_errors(); | |
36 | } |