SWITCH_DECLARE_CONSTRUCTOR EventConsumer(const char *event_name = NULL, const char *subclass_name = "");
SWITCH_DECLARE_CONSTRUCTOR ~ EventConsumer();
SWITCH_DECLARE(int) bind(const char *event_name, const char *subclass_name = "");
- SWITCH_DECLARE(Event *) pop(int block = 0);
+ SWITCH_DECLARE(Event *) pop(int block = 0, int timeout = 0);
};
#ifdef SWIG
}
-SWITCH_DECLARE(Event *) EventConsumer::pop(int block)
+SWITCH_DECLARE(Event *) EventConsumer::pop(int block, int timeout)
{
void *pop = NULL;
Event *ret = NULL;
switch_event_t *event;
if (block) {
- switch_queue_pop(events, &pop);
+ if (timeout > 0) {
+ switch_queue_pop_timeout(events, &pop, (switch_interval_time_t) timeout * 1000); // millisec rather than microsec
+ } else {
+ switch_queue_pop(events, &pop);
+ }
} else {
switch_queue_trypop(events, &pop);
}