]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/example/scoped_thread.cpp
1 // (C) Copyright 2009-2012 Anthony Williams
2 // (C) Copyright 2012 Vicente Botet
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #define BOOST_THREAD_VERSION 3
10 #include <boost/thread/scoped_thread.hpp>
12 void do_something(int& i
)
31 for (unsigned j
= 0; j
< 1000000; ++j
)
38 void do_something_in_current_thread()
45 int some_local_state
=0;
46 boost::strict_scoped_thread
<> t( (boost::thread(func(some_local_state
))));
48 do_something_in_current_thread();
51 int some_local_state
=0;
52 boost::thread
t(( func(some_local_state
) ));
53 boost::strict_scoped_thread
<> g( (boost::move(t
)) );
55 do_something_in_current_thread();
58 int some_local_state
=0;
59 boost::scoped_thread
<> t( (boost::thread(func(some_local_state
))));
64 do_something_in_current_thread();
68 int some_local_state
=0;
69 boost::thread
t(( func(some_local_state
) ));
70 boost::scoped_thread
<> g( (boost::move(t
)) );
74 do_something_in_current_thread();
78 boost::scoped_thread
<> g( &f
, 1, 2 );
79 do_something_in_current_thread();