annotate DEPENDENCIES/generic/include/boost/signals2/shared_connection_block.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost.Signals2 library
Chris@16 2
Chris@16 3 // Copyright Frank Mori Hess 2007-2008.
Chris@16 4 // Use, modification and
Chris@16 5 // distribution is subject to the Boost Software License, Version
Chris@16 6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 // For more information, see http://www.boost.org
Chris@16 10
Chris@16 11 #ifndef BOOST_SIGNALS2_SHARED_CONNECTION_BLOCK_HPP
Chris@16 12 #define BOOST_SIGNALS2_SHARED_CONNECTION_BLOCK_HPP
Chris@16 13
Chris@16 14 #include <boost/shared_ptr.hpp>
Chris@16 15 #include <boost/signals2/connection.hpp>
Chris@16 16 #include <boost/weak_ptr.hpp>
Chris@16 17
Chris@16 18 namespace boost
Chris@16 19 {
Chris@16 20 namespace signals2
Chris@16 21 {
Chris@16 22 class shared_connection_block
Chris@16 23 {
Chris@16 24 public:
Chris@16 25 shared_connection_block(const signals2::connection &conn = signals2::connection(),
Chris@16 26 bool initially_blocked = true):
Chris@16 27 _weak_connection_body(conn._weak_connection_body)
Chris@16 28 {
Chris@16 29 if(initially_blocked) block();
Chris@16 30 }
Chris@16 31 void block()
Chris@16 32 {
Chris@16 33 if(blocking()) return;
Chris@16 34 boost::shared_ptr<detail::connection_body_base> connection_body(_weak_connection_body.lock());
Chris@16 35 if(connection_body == 0)
Chris@16 36 {
Chris@16 37 // Make _blocker non-empty so the blocking() method still returns the correct value
Chris@16 38 // after the connection has expired.
Chris@16 39 _blocker.reset(static_cast<int*>(0));
Chris@16 40 return;
Chris@16 41 }
Chris@16 42 _blocker = connection_body->get_blocker();
Chris@16 43 }
Chris@16 44 void unblock()
Chris@16 45 {
Chris@16 46 _blocker.reset();
Chris@16 47 }
Chris@16 48 bool blocking() const
Chris@16 49 {
Chris@16 50 shared_ptr<void> empty;
Chris@16 51 return _blocker < empty || empty < _blocker;
Chris@16 52 }
Chris@16 53 signals2::connection connection() const
Chris@16 54 {
Chris@16 55 return signals2::connection(_weak_connection_body);
Chris@16 56 }
Chris@16 57 private:
Chris@16 58 boost::weak_ptr<detail::connection_body_base> _weak_connection_body;
Chris@16 59 shared_ptr<void> _blocker;
Chris@16 60 };
Chris@16 61 }
Chris@16 62 } // end namespace boost
Chris@16 63
Chris@16 64 #endif // BOOST_SIGNALS2_SHARED_CONNECTION_BLOCK_HPP