37 EventSwitch::EventSwitch()
42 EventSwitch::~EventSwitch()
73 while (!this->
empty())
84 return (_low_queue.empty() && _queue.empty() && _prio_queue.empty());
87 void EventSwitch::process()
89 EventSwitch::Task *t = NULL;
94 if (!_running)
return;
96 while (this->
empty() && !_shutdown)
101 if (!_prio_queue.empty())
103 t = _prio_queue.front();
104 _prio_queue.pop_front();
106 else if (!_queue.empty())
111 else if (!_low_queue.empty())
113 t = _low_queue.front();
114 _low_queue.pop_front();
134 t->processor.process(t->event);
144 std::list<Worker*> wlist;
146 for (
size_t i = 0; i < threads; ++i)
160 for (std::list<Worker*>::iterator iter = wlist.begin(); iter != wlist.end(); ++iter)
182 EventSwitch::Task *t =
new EventSwitch::Task(proc, evt);
186 s._prio_queue.push_back(t);
188 else if (evt->
prio < 0)
190 s._low_queue.push_back(t);
194 s._queue.push_back(t);
218 const std::string EventSwitch::getName()
const
220 return "EventSwitch";
224 : processor(proc), event(evt)
228 EventSwitch::Task::~Task()
236 EventSwitch::Worker::Worker(EventSwitch &sw)
240 EventSwitch::Worker::~Worker()
243 void EventSwitch::Worker::run() throw ()
251 void EventSwitch::Worker::__cancellation() throw ()