switch_log_init(runtime.memory_pool, runtime.colorize_console);
if (flags & SCF_MINIMAL) return SWITCH_STATUS_SUCCESS;
-
+
runtime.tipping_point = 0;
runtime.timer_affinity = -1;
runtime.microseconds_per_tick = 20000;
switch_core_min_idle_cpu(atof(val));
} else if (!strcasecmp(var, "tipping-point") && !zstr(val)) {
runtime.tipping_point = atoi(val);
+ } else if (!strcasecmp(var, "initial-event-threads") && !zstr(val)) {
+ int tmp = atoi(val);
+
+
+ if (tmp > runtime.cpu_count / 2) {
+ tmp = runtime.cpu_count / 2;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This value cannot be higher than %d so setting it to that value\n",
+ runtime.cpu_count / 2);
+ }
+
+ if (tmp < 1) {
+ tmp = 1;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This value cannot be lower than 1 so setting it to that level\n");
+ }
+
+ switch_event_launch_dispatch_threads(tmp);
+
} else if (!strcasecmp(var, "1ms-timer") && switch_true(val)) {
runtime.microseconds_per_tick = 1000;
} else if (!strcasecmp(var, "timer-affinity") && !zstr(val)) {
#include <switch.h>
#include <switch_event.h>
+
//#define SWITCH_EVENT_RECYCLE
#define DISPATCH_QUEUE_LEN 100
//#define DEBUG_DISPATCH_QUEUES
static switch_queue_t *EVENT_RECYCLE_QUEUE = NULL;
static switch_queue_t *EVENT_HEADER_RECYCLE_QUEUE = NULL;
#endif
-static void launch_dispatch_threads(uint32_t max, switch_memory_pool_t *pool);
static char *my_dup(const char *s)
{
if (launch) {
if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
- launch_dispatch_threads(SOFT_MAX_DISPATCH + 1, RUNTIME_POOL);
+ switch_event_launch_dispatch_threads(SOFT_MAX_DISPATCH + 1);
}
}
return SWITCH_STATUS_SUCCESS;
}
-static void launch_dispatch_threads(uint32_t max, switch_memory_pool_t *pool)
+SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max)
{
switch_threadattr_t *thd_attr;
uint32_t index = 0;
int launched = 0;
uint32_t sanity = 200;
+ switch_memory_pool_t *pool = RUNTIME_POOL;
+
if (max > MAX_DISPATCH) {
return;
}
for (index = SOFT_MAX_DISPATCH; index < max && index < MAX_DISPATCH; index++) {
if (EVENT_DISPATCH_QUEUE_THREADS[index]) {
+ printf("Index exists continue\n");
continue;
}
switch_threadattr_priority_increase(thd_attr);
switch_thread_create(&EVENT_DISPATCH_QUEUE_THREADS[index], thd_attr, switch_event_dispatch_thread, EVENT_DISPATCH_QUEUE, pool);
while(--sanity && !EVENT_DISPATCH_QUEUE_RUNNING[index]) switch_yield(10000);
+
if (index == 1) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Create event dispatch thread %d\n", index);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Create event dispatch thread %d\n", index);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Create additional event dispatch thread %d\n", index);
}
launched++;
- break;
}
SOFT_MAX_DISPATCH = index;
//switch_threadattr_priority_increase(thd_attr);
switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, pool);
- launch_dispatch_threads(1, RUNTIME_POOL);
+ switch_event_launch_dispatch_threads(1);
//switch_thread_create(&EVENT_QUEUE_THREADS[0], thd_attr, switch_event_thread, EVENT_QUEUE[0], RUNTIME_POOL);
//switch_thread_create(&EVENT_QUEUE_THREADS[1], thd_attr, switch_event_thread, EVENT_QUEUE[1], RUNTIME_POOL);