From b992e29640d02246dfe3bbd84425a834f3e45bb6 Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Wed, 16 Nov 2011 16:00:14 -0600 Subject: [PATCH] FS-3553 --resolve --- src/include/switch_cpp.h | 2 +- src/switch_cpp.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 5177c467ae..44e85185a6 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -189,7 +189,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod 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 diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 47bc1d50ec..91d0980444 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -85,14 +85,18 @@ SWITCH_DECLARE(int) EventConsumer::bind(const char *event_name, const char *subc } -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); }