forked from boostorg/smart_ptr
Small modifications.
[SVN r13212]
This commit is contained in:
@ -84,7 +84,7 @@ char const * title = "Using POSIX threads";
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
extern "C" void* common_thread_routine(void * pv)
|
extern "C" void * common_thread_routine(void * pv)
|
||||||
{
|
{
|
||||||
abstract_thread * pt = static_cast<abstract_thread *>(pv);
|
abstract_thread * pt = static_cast<abstract_thread *>(pv);
|
||||||
pt->run();
|
pt->run();
|
||||||
@ -145,9 +145,17 @@ void test(boost::shared_ptr<int> const & pi)
|
|||||||
|
|
||||||
int const m = 16; // threads
|
int const m = 16; // threads
|
||||||
|
|
||||||
|
#if defined(BOOST_LWM_USE_CRITICAL_SECTION)
|
||||||
|
char const * implementation = "critical section";
|
||||||
|
#elif defined(BOOST_LWM_USE_PTHREADS)
|
||||||
|
char const * implementation = "pthread_mutex";
|
||||||
|
#else
|
||||||
|
char const * implementation = "spinlock";
|
||||||
|
#endif
|
||||||
|
|
||||||
int test_main( int, char ** )
|
int test_main( int, char ** )
|
||||||
{
|
{
|
||||||
std::printf("%s: %d threads, %d iterations, ", title, m, n);
|
std::printf("%s: %s, %d threads, %d iterations: ", title, implementation, m, n);
|
||||||
|
|
||||||
boost::shared_ptr<int> pi(new int(42));
|
boost::shared_ptr<int> pi(new int(42));
|
||||||
|
|
||||||
@ -167,7 +175,7 @@ int test_main( int, char ** )
|
|||||||
|
|
||||||
t = std::clock() - t;
|
t = std::clock() - t;
|
||||||
|
|
||||||
std::printf("%.4f seconds.\n", static_cast<double>(t) / CLOCKS_PER_SEC);
|
std::printf("\n\n%.3f seconds.\n", static_cast<double>(t) / CLOCKS_PER_SEC);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user