1 // Boost.Signals library
3 // Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu)
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
14 // For more information, see http://www.boost.org
16 #include <boost/signals/connection.hpp>
20 namespace BOOST_SIGNALS_NAMESPACE {
21 void connection::disconnect() const
23 if (this->connected()) {
24 // Make sure we have a reference to the basic_connection object,
25 // because 'this' may disappear
26 shared_ptr<detail::basic_connection> local_con = con;
28 void (*signal_disconnect)(void*, void*) = local_con->signal_disconnect;
30 // Note that this connection no longer exists
31 // Order is important here: we could get into an infinite loop if this
32 // isn't cleared before we try the disconnect.
33 local_con->signal_disconnect = 0;
36 signal_disconnect(local_con->signal, local_con->signal_data);
38 // Disconnect all bound objects
39 typedef std::list<BOOST_SIGNALS_NAMESPACE::detail::bound_object>::iterator iterator;
40 for (iterator i = local_con->bound_objects.begin();
41 i != local_con->bound_objects.end(); ++i) {
42 assert(i->disconnect != 0);
43 i->disconnect(i->obj, i->data);
47 } // end namespace boost
48 } // end namespace boost
51 // Explicit instantiations to keep everything in the library
52 template class std::list<boost::BOOST_SIGNALS_NAMESPACE::detail::bound_object>;