mirror of
				https://github.com/boostorg/smart_ptr.git
				synced 2025-11-04 01:31:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			685 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			685 B
		
	
	
	
		
			C++
		
	
	
	
	
	
 | 
						|
// lw_thread_test.cpp
 | 
						|
//
 | 
						|
// Copyright 2018 Peter Dimov
 | 
						|
// Distributed under the Boost Software License, Version 1.0.
 | 
						|
 | 
						|
#include <boost/smart_ptr/detail/lightweight_thread.hpp>
 | 
						|
#include <boost/smart_ptr/detail/atomic_count.hpp>
 | 
						|
#include <boost/core/lightweight_test.hpp>
 | 
						|
 | 
						|
boost::detail::atomic_count count( 0 );
 | 
						|
 | 
						|
void f()
 | 
						|
{
 | 
						|
    ++count;
 | 
						|
}
 | 
						|
 | 
						|
int main()
 | 
						|
{
 | 
						|
    int const N = 4;
 | 
						|
    boost::detail::lw_thread_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 )
 | 
						|
    {
 | 
						|
        boost::detail::lw_thread_join( th[ i ] );
 | 
						|
    }
 | 
						|
 | 
						|
    BOOST_TEST_EQ( count, N );
 | 
						|
 | 
						|
    return boost::report_errors();
 | 
						|
}
 |