mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-23 01:50:05 +00:00
[core] add switch_thread_pool_wait
This commit is contained in:
parent
0239b80fb5
commit
aee8701d01
@ -67,6 +67,7 @@ typedef struct switch_thread_data_s {
|
|||||||
switch_thread_start_t func;
|
switch_thread_start_t func;
|
||||||
void *obj;
|
void *obj;
|
||||||
int alloc;
|
int alloc;
|
||||||
|
int running;
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
} switch_thread_data_t;
|
} switch_thread_data_t;
|
||||||
|
|
||||||
@ -851,7 +852,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(_In_ switch_co
|
|||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_thread_pool_launch_thread(switch_thread_data_t **tdp);
|
SWITCH_DECLARE(switch_status_t) switch_thread_pool_launch_thread(switch_thread_data_t **tdp);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session);
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_thread_pool_wait(switch_thread_data_t *td, int ms);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Retrieve a pointer to the channel object associated with a given session
|
\brief Retrieve a pointer to the channel object associated with a given session
|
||||||
\param session the session to retrieve from
|
\param session the session to retrieve from
|
||||||
|
@ -1779,8 +1779,10 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_worker(switch_th
|
|||||||
#ifdef DEBUG_THREAD_POOL
|
#ifdef DEBUG_THREAD_POOL
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Processing\n", (long) (intptr_t) thread);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Processing\n", (long) (intptr_t) thread);
|
||||||
#endif
|
#endif
|
||||||
|
td->running = 1;
|
||||||
td->func(thread, td->obj);
|
td->func(thread, td->obj);
|
||||||
|
td->running = 0;
|
||||||
|
|
||||||
if (td->pool) {
|
if (td->pool) {
|
||||||
switch_memory_pool_t *pool = td->pool;
|
switch_memory_pool_t *pool = td->pool;
|
||||||
td = NULL;
|
td = NULL;
|
||||||
@ -1896,6 +1898,15 @@ SWITCH_DECLARE(switch_status_t) switch_thread_pool_launch_thread(switch_thread_d
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_thread_pool_wait(switch_thread_data_t *td, int ms)
|
||||||
|
{
|
||||||
|
while(!td->running && --ms > 0) {
|
||||||
|
switch_cond_next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ms > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session)
|
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
switch_status_t status = SWITCH_STATUS_INUSE;
|
switch_status_t status = SWITCH_STATUS_INUSE;
|
||||||
@ -1920,7 +1931,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_pool_launch(switch_co
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_session_t *session)
|
SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user