3 * Author: Lukas Krejci <krejci.l@centrum.cz>, (C) 2008
4 * Copyright: See COPYING file that comes with this distribution
7 #include <beacon/detail/signal_base.hpp>
8 #include <beacon/detail/connection_impl.hpp>
14 //a helper function to signal_base::do_disconnect and signal_base::clear
15 void invalidate_slot(signal_base::slot_list_type::iterator
& pos
) {
17 pos
->loop
->dequeue(pos
->connection
->token());
22 //a helper for do_connect methods
23 intrusive_ptr
<connection_impl_base
> signal_base::_init_connection(signal_base::slot_list_item
& item
) {
25 _slots
.push_back(item
);
27 connection_impl
* inited
= new connection_impl(this, --_slots
.end());
29 intrusive_ptr
<connection_impl_base
> ip(inited
);
31 slot_list_item
& ret
= _slots
.back();
32 ret
.connection
.swap(ip
);
34 return intrusive_ptr
<connection_impl_base
>(ret
.connection
);
37 intrusive_ptr
<connection_impl_base
> signal_base::do_connect(slot_base
* slot
, trackable
* obj
) {
42 item
.loop
= obj
->current_event_loop();
47 intrusive_ptr
<connection_impl_base
> ret
= _init_connection(item
);
49 //this must be inside lock so that we can be sure that
50 //we do not disconnect the connection before it was inited
51 //in the trackable, otherwise we could have races.
53 obj
->add_connection(ret
);
61 intrusive_ptr
<connection_impl_base
> signal_base::do_connect(slot_base
* slot
, event_loop
& loop
) {
68 intrusive_ptr
<connection_impl_base
> ret
= _init_connection(item
);
75 void signal_base::do_disconnect(slot_list_type::iterator pos
) {
82 void signal_base::clear() {
85 for(slot_list_type::iterator it
= _slots
.begin(); it
!= _slots
.end(); ++it
) {
94 signal_base::slot_list_type
signal_base::get_slots_copy() {
96 slot_list_type ret
= _slots
;