14 virtual void process() = 0;
15 virtual void clear() = 0;
22 typedef T StorageType;
24 static void store(T& lhs, T2&& rhs) { lhs = forward<T2>(rhs); }
25 static T& load(T& lhs) {
return lhs; }
30 struct SlotQueueArg<T&>
32 typedef T* StorageType;
34 static void store(T*& lhs, T2&& rhs) { lhs = &rhs; }
35 static T& load(T* lhs) {
return *lhs; }
38 template<
class Signal,
class F,
class Seq = mt::make_
idxseq<Signal::arity>>
40 template<
class Signal,
class F,
szt... Seq>
41 class SlotQueue<Signal,F,mt::
idxseq<Seq...>> :
public priv::SlotSignal<Signal>,
public SlotQueueBase
43 typedef priv::SlotSignal<Signal> Super;
45 SlotQueue(
const Id&
id, F&& f) : Super(id), _f(forward<F>(f)) {}
47 virtual void operator()(
const typename Signal::template param<Seq>&... args)
50 _args.push_back(Args());
51 Args& queued = _args.back();
52 mt_unpackEval(priv::SlotQueueArg<
typename Signal::template param<Seq>>::store(get<Seq>(queued), args));
55 virtual void process()
58 for (
auto& args : _args)
59 _f(priv::SlotQueueArg<
typename Signal::template param<Seq>>::load(get<Seq>(args))...);
70 typedef tuple<typename priv::SlotQueueArg<typename Signal::template param<Seq>>::StorageType...> Args;
73 vector<Args, SmallAllocator<Args>> _args;
95 template<
class Signal,
class F>
98 return *
new ListenerQueue(*
new priv::SlotQueue<Signal,F>(
id, forward<F>(f)),
obj,
id);
107 template<
class SlotQueue>
109 Listener(slot, obj, id), _slot(slot) {};
111 priv::SlotQueueBase& _slot;
SharedPtr< ListenerQueue > Ptr
Definition: ListenerQueue.h:91
Listener that holds queued slot for delayed processing of signals.
Definition: ListenerQueue.h:88
const void * obj() const
Get object instance for listener identification.
Definition: Listener.h:29
void clear()
Remove all signals stored in queue.
Definition: ListenerQueue.h:104
Combined intrusive/non-intrusive smart pointer. Can reference and share any object automatically...
Definition: SharedPtr.h:175
void process()
Dispatch all signals stored in queue, clears queue when done.
Definition: ListenerQueue.h:102
static auto _
Definition: Module.cpp:8
Holds a slot that can receive signals.
Definition: Listener.h:11
static ListenerQueue & create(F &&f, const void *obj=nullptr, const Id &id=idnull)
Construct with slot to receive Signal using function F. The object instance and id are used together ...
Definition: ListenerQueue.h:96
#define idnull
Null id.
Definition: Id.h:124
size_t szt
Size type, shorthand for size_t.
Definition: Core.h:90
UniqueLock< SpinLock > Scoped
Definition: Spin.h:20
Holds a name string and its hashed value for fast comparison ops. See String Identifier.
Definition: Id.h:25
SlotBase & slot() const
Get slot.
Definition: Listener.h:27
Global Honeycomb namespace.
SharedPtr< const ListenerQueue > ConstPtr
Definition: ListenerQueue.h:92