class EventConsumer {
protected:
switch_memory_pool_t *pool;
+ int ready;
public:
switch_queue_t *events;
switch_event_types_t e_event_id;
SWITCH_DECLARE_CONSTRUCTOR ~ EventConsumer();
SWITCH_DECLARE(int) bind(const char *event_name, const char *subclass_name = "");
SWITCH_DECLARE(Event *) pop(int block = 0, int timeout = 0);
+ SWITCH_DECLARE(void) cleanup();
};
#ifdef SWIG
if (switch_queue_trypush(E->events, dup) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot queue any more events.....\n");
+ switch_event_destroy(&dup);
}
}
bind(event_name, subclass_name);
}
+ ready = 1;
}
SWITCH_DECLARE(int) EventConsumer::bind(const char *event_name, const char *subclass_name)
switch_event_types_t event_id = SWITCH_EVENT_CUSTOM;
switch_name_event(event_name, &event_id);
+ if (!ready) {
+ return 0;
+ }
+
if (zstr(subclass_name)) {
subclass_name = NULL;
void *pop = NULL;
Event *ret = NULL;
switch_event_t *event;
+
+ if (!ready) {
+ return NULL;
+ }
if (block) {
if (timeout > 0) {
return ret;
}
-SWITCH_DECLARE_CONSTRUCTOR EventConsumer::~EventConsumer()
+SWITCH_DECLARE(void) EventConsumer::cleanup()
{
+
uint32_t i;
+ void *pop;
+
+ if (!ready) {
+ return;
+ }
+
+ ready = 0;
for (i = 0; i < node_index; i++) {
switch_event_unbind(&enodes[i]);
}
+ node_index = 0;
+
if (events) {
switch_queue_interrupt_all(events);
}
+ while(switch_queue_trypop(events, &pop) == SWITCH_STATUS_SUCCESS) {
+ switch_event_t *event = (switch_event_t *) pop;
+ switch_event_destroy(&event);
+ }
+
+
switch_core_destroy_memory_pool(&pool);
+
+}
+
+
+SWITCH_DECLARE_CONSTRUCTOR EventConsumer::~EventConsumer()
+{
+ cleanup();
}
SWITCH_DECLARE_CONSTRUCTOR IVRMenu::IVRMenu(IVRMenu *main,