forked from boostorg/smart_ptr
Add lw_thread_test
This commit is contained in:
@@ -270,3 +270,5 @@ run lsp_convertible_test.cpp ;
|
|||||||
run lsp_convertible_test2.cpp ;
|
run lsp_convertible_test2.cpp ;
|
||||||
|
|
||||||
run make_shared_array_tmp_test.cpp ;
|
run make_shared_array_tmp_test.cpp ;
|
||||||
|
|
||||||
|
run lw_thread_test.cpp : : : <threading>multi ;
|
||||||
|
36
test/lw_thread_test.cpp
Normal file
36
test/lw_thread_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
// lw_thread_test.cpp
|
||||||
|
//
|
||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
|
#include <boost/detail/lightweight_thread.hpp>
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#include <boost/smart_ptr/detail/atomic_count.hpp>
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
Reference in New Issue
Block a user