mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-02 01:25:11 +00:00
use more of apr-utils in the event stuff
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@191 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
e60fbc2267
commit
3e0234219b
7 files changed
+229
-105
No files matched your search
@@ -60,6 +60,50 @@ static switch_loadable_module_interface event_test_module_interface = {
|
||||
|
||||
#define MY_EVENT_COOL "test::cool"
|
||||
|
||||
|
||||
//#define TORTURE_ME
|
||||
|
||||
#ifdef TORTURE_ME
|
||||
#define TTHREADS 500
|
||||
static int THREADS = 0;
|
||||
|
||||
static void *torture_thread(switch_thread *thread, void *obj)
|
||||
{
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
switch_core_thread_session *ts = obj;
|
||||
switch_event *event;
|
||||
|
||||
z = THREADS++;
|
||||
|
||||
while(THREADS > 0) {
|
||||
int x;
|
||||
for(x = 0; x < 1; x++) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_COOL) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, "event_info", "hello world %d %d", z, y++);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
switch_yield(100000);
|
||||
}
|
||||
|
||||
if (ts->pool) {
|
||||
switch_memory_pool *pool = ts->pool;
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Thread Ended\n");
|
||||
}
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
||||
{
|
||||
THREADS = -1;
|
||||
switch_yield(100000);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename) {
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &event_test_module_interface;
|
||||
@@ -69,32 +113,21 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_inte
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
#ifdef TORTURE_ME
|
||||
if (switch_event_bind((char *)modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind!\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (1) {
|
||||
int x = 0;
|
||||
for(x = 0 ; x < TTHREADS ; x++) {
|
||||
switch_core_launch_thread(torture_thread, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
//#define TORTURE_ME
|
||||
|
||||
#ifdef TORTURE_ME
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
||||
{
|
||||
int y = 0;
|
||||
switch_event *event;
|
||||
|
||||
for(;;) {
|
||||
int x;
|
||||
for(x = 0; x < 100; x++) {
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_COOL) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, "event_info", "hello world %d", y++);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
switch_yield(100000);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user