1 // Boost.Signals2 library
3 // Copyright Frank Mori Hess 2007-2008.
4 // Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
11 #ifndef BOOST_SIGNALS2_SHARED_CONNECTION_BLOCK_HPP
12 #define BOOST_SIGNALS2_SHARED_CONNECTION_BLOCK_HPP
14 #include <boost/shared_ptr.hpp>
15 #include <boost/signals2/connection.hpp>
16 #include <boost/weak_ptr.hpp>
22 class shared_connection_block
25 shared_connection_block(const connection
&conn
):
26 _weak_connection_body(conn
._weak_connection_body
)
32 if(blocking()) return;
33 boost::shared_ptr
<detail::connection_body_base
> connection_body(_weak_connection_body
.lock());
34 if(connection_body
== 0)
36 // Make _blocker non-empty so the blocking() method still returns the correct value
37 // after the connection has expired.
38 _blocker
.reset(static_cast<int*>(0));
41 _blocker
= connection_body
->get_blocker();
49 shared_ptr
<void> empty
;
50 return _blocker
< empty
|| empty
< _blocker
;
53 boost::weak_ptr
<detail::connection_body_base
> _weak_connection_body
;
54 shared_ptr
<void> _blocker
;
57 } // end namespace boost
59 #endif // BOOST_SIGNALS2_SHARED_CONNECTION_BLOCK_HPP