// testonce.cpp // // (C) Copyright 2005 Anthony Williams // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include "once.hpp" #include #include #include #include unsigned counter=0; void increment_counter() { ++counter; } void test_once() { boost::once_flag flag=BOOST_ONCE_INIT; counter=0; unsigned const loop_count=1000000; for(unsigned i=0;i(thread_counter)); return 0; } void test_once_multiple_threads() { unsigned const number_of_threads=20; counter=0; HANDLE handles[number_of_threads]={0}; unsigned thread_count=0; for(unsigned i=0;i