diff --git a/test/Jamfile b/test/Jamfile index 5fb9edf..c9c7b67 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -270,3 +270,5 @@ run lsp_convertible_test.cpp ; run lsp_convertible_test2.cpp ; run make_shared_array_tmp_test.cpp ; + +run lw_thread_test.cpp : : : multi ; diff --git a/test/lw_thread_test.cpp b/test/lw_thread_test.cpp new file mode 100644 index 0000000..1da8ed5 --- /dev/null +++ b/test/lw_thread_test.cpp @@ -0,0 +1,36 @@ + +// lw_thread_test.cpp +// +// Copyright 2018 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. + +#include +#include +#include + +boost::detail::atomic_count count( 0 ); + +void f() +{ + ++count; +} + +int main() +{ + int const N = 4; + pthread_t th[ N ] = {}; + + for( int i = 0; i < N; ++i ) + { + boost::detail::lw_thread_create( th[ i ], f ); + } + + for( int i = 0; i < N; ++i ) + { + pthread_join( th[ i ], 0 ); + } + + BOOST_TEST_EQ( count, N ); + + return boost::report_errors(); +}