]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/exception/example/cloning_2.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / exception / example / cloning_2.cpp
1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
2
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 //This example shows how to transport cloning-enabled boost::exceptions between threads.
7
8 #include <boost/exception_ptr.hpp>
9 #include <boost/thread.hpp>
10 #include <boost/bind.hpp>
11
12 void do_work(); //throws cloning-enabled boost::exceptions
13
14 void
15 worker_thread( boost::exception_ptr & error )
16 {
17 try
18 {
19 do_work();
20 error = boost::exception_ptr();
21 }
22 catch(
23 ... )
24 {
25 error = boost::current_exception();
26 }
27 }
28
29 // ...continued
30
31 void
32 work()
33 {
34 boost::exception_ptr error;
35 boost::thread t( boost::bind(worker_thread,boost::ref(error)) );
36 t.join();
37 if( error )
38 boost::rethrow_exception(error);
39 }