3 * Author: Lukas Krejci <krejci.l@centrum.cz>, (C) 2008
4 * Copyright: See COPYING file that comes with this distribution
7 #ifndef BEACON_signal_base_H
8 #define BEACON_signal_base_H
10 #include <beacon/event_loop.hpp>
11 #include <beacon/intrusive_ptr.hpp>
12 #include <beacon/reference_countable.hpp>
13 #include <beacon/detail/slot.hpp>
14 #include <beacon/trackable.hpp>
15 #include <beacon/detail/connection_impl_base.hpp>
16 #include <beacon/detail/quick_wait.hpp>
21 #include <atomic_ops.h>
29 class connection_impl
;
31 class signal_base
: public reference_countable
{
32 friend class connection_impl
;
35 //we represent the slot as just a slot_base * so that this
36 //class doesn't have to be templated. The subclasses will
37 //know what concrete slot type to cast it to...
38 struct slot_list_item
{
40 intrusive_ptr
<connection_impl_base
> connection
;
43 slot_list_item() : slot(0), connection(), loop(0) {}
45 typedef std::list
<slot_list_item
> slot_list_type
;
48 * Disconnects all slots from this signal.
54 signal_base() : _slots(), _slots_guard(AO_TS_INITIALIZER
) {}
57 * Initializes the connection.
59 intrusive_ptr
<connection_impl_base
> do_connect(slot_base
* slot
, trackable
* obj
);
62 * Removes the connection record identified by the iterator from the
65 void do_disconnect(slot_list_type::iterator pos
);
68 * Returns a copy of the slot list as it was at the time
69 * of the call. This operation is thread safe as it made sure
70 * that no modifications are possible while making this copy.
72 slot_list_type
get_slots_copy();
75 slot_list_type _slots
;