bumped version to 0.1.0
[beacon-ss.git] / src / beacon / trackable.cpp
blobe978ab8136caa62e7e06ace260eee9fcb423ecf2
1 /**
2 * beacon
3 * Author: Lukas Krejci <krejci.l@centrum.cz>, (C) 2008
4 * Copyright: See COPYING file that comes with this distribution
5 */
7 #include <beacon/trackable.hpp>
8 #include <beacon/detail/quick_wait.hpp>
9 #include <algorithm>
11 namespace beacon {
13 void disconnect(intrusive_ptr<detail::connection_impl_base> & con) {
14 con->disconnect();
17 trackable::~trackable() {
18 detail::wait(_cons_guard);
19 std::for_each(_connections.begin(), _connections.end(), &disconnect);
20 detail::notify(_cons_guard);
23 trackable & trackable::operator=(trackable const & rhs) {
25 detail::wait(_cons_guard);
26 std::for_each(_connections.begin(), _connections.end(), &disconnect);
27 _connections.clear();
28 detail::notify(_cons_guard);
30 _evq = rhs.current_event_queue();
31 return *this;
34 void trackable::add_connection(intrusive_ptr<detail::connection_impl_base> con) {
35 detail::wait(_cons_guard);
36 _connections.push_back(con);
37 detail::notify(_cons_guard);