Threads and Process Functions
[Brought To You By APR]

Collaboration diagram for Threads and Process Functions:

Typedefs

typedef apr_thread_t switch_thread_t
typedef apr_threadattr_t switch_threadattr_t
typedef void *SWITCH_THREAD_FUNC * switch_thread_start_t (switch_thread_t *, void *)

Functions

switch_status_t switch_threadattr_stacksize_set (switch_threadattr_t *attr, switch_size_t stacksize)
switch_status_t switch_threadattr_priority_increase (switch_threadattr_t *attr)
switch_status_t switch_threadattr_create (switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
switch_status_t switch_threadattr_detach_set (switch_threadattr_t *attr, int32_t on)
switch_status_t switch_thread_create (switch_thread_t **new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont)


Typedef Documentation

typedef void* SWITCH_THREAD_FUNC* switch_thread_start_t(switch_thread_t *, void *)

The prototype for any APR thread worker functions. typedef void *(SWITCH_THREAD_FUNC *switch_thread_start_t)(switch_thread_t*, void*);

Definition at line 987 of file switch_apr.h.

typedef struct apr_thread_t switch_thread_t

Opaque Thread structure.

Definition at line 978 of file switch_apr.h.

typedef struct apr_threadattr_t switch_threadattr_t

Opaque Thread attributes structure.

Definition at line 981 of file switch_apr.h.


Function Documentation

switch_status_t switch_thread_create ( switch_thread_t **  new_thread,
switch_threadattr_t attr,
switch_thread_start_t  func,
void *  data,
switch_memory_pool_t cont 
)

Create a new thread of execution

Parameters:
new_thread The newly created thread handle.
attr The threadattr to use to determine how to create the thread
func The function to start the new thread in
data Any data to be passed to the starting function
cont The pool to use

Definition at line 659 of file switch_apr.c.

References switch_core_memory_pool_set_data(), and TT_KEY.

Referenced by chat_thread_start(), launch_collect_thread(), launch_dispatch_threads(), speech_callback(), switch_core_launch_thread(), switch_core_memory_init(), switch_core_session_launch_thread(), switch_core_session_thread_launch(), switch_core_sqldb_start(), switch_event_fire_detailed(), switch_ivr_broadcast_in_thread(), switch_ivr_enterprise_originate(), switch_ivr_session_echo(), switch_log_init(), switch_nat_thread_start(), switch_scheduler_task_thread_start(), switch_system_thread(), switch_xml_free_in_thread(), task_thread_loop(), and unicast_thread_launch().

00661 {
00662         switch_core_memory_pool_set_data(cont, "_in_thread", TT_KEY);
00663         return apr_thread_create(new_thread, attr, func, data, cont);
00664 }

switch_status_t switch_threadattr_create ( switch_threadattr_t **  new_attr,
switch_memory_pool_t pool 
)

Create and initialize a new threadattr variable

Parameters:
new_attr The newly created threadattr.
pool The pool to use

Definition at line 617 of file switch_apr.c.

Referenced by chat_thread_start(), launch_collect_thread(), launch_dispatch_threads(), speech_callback(), switch_core_launch_thread(), switch_core_memory_init(), switch_core_session_launch_thread(), switch_core_session_thread_launch(), switch_core_sqldb_start(), switch_event_fire_detailed(), switch_ivr_broadcast_in_thread(), switch_ivr_enterprise_originate(), switch_ivr_session_echo(), switch_log_init(), switch_nat_thread_start(), switch_scheduler_task_thread_start(), switch_system_thread(), switch_xml_free_in_thread(), task_thread_loop(), and unicast_thread_launch().

00618 {
00619         return apr_threadattr_create(new_attr, pool);
00620 }

switch_status_t switch_threadattr_detach_set ( switch_threadattr_t attr,
int32_t  on 
)

Set if newly created threads should be created in detached state.

Parameters:
attr The threadattr to affect
on Non-zero if detached threads should be created.

Definition at line 622 of file switch_apr.c.

Referenced by launch_collect_thread(), speech_callback(), switch_core_memory_init(), switch_core_session_launch_thread(), switch_core_session_thread_launch(), switch_ivr_broadcast_in_thread(), switch_ivr_session_echo(), switch_log_init(), switch_nat_thread_start(), switch_scheduler_task_thread_start(), switch_system_thread(), switch_xml_free_in_thread(), task_thread_loop(), and unicast_thread_launch().

00623 {
00624         return apr_threadattr_detach_set(attr, on);
00625 }

switch_status_t switch_threadattr_priority_increase ( switch_threadattr_t attr  ) 

Definition at line 639 of file switch_apr.c.

References apr_threadattr_t::attr, and SWITCH_STATUS_SUCCESS.

Referenced by launch_dispatch_threads(), switch_core_launch_thread(), and switch_event_fire_detailed().

00640 {
00641         int stat = 0;
00642 #ifndef WIN32
00643         struct sched_param param;
00644         struct apr_threadattr_t *myattr = attr;
00645 
00646         pthread_attr_getschedparam(&myattr->attr, &param);
00647         param.sched_priority = 1;
00648         stat = pthread_attr_setschedparam(&myattr->attr, &param);
00649 
00650         if (stat == 0) {
00651                 return SWITCH_STATUS_SUCCESS;
00652         }
00653 #endif
00654         return stat;
00655 }

switch_status_t switch_threadattr_stacksize_set ( switch_threadattr_t attr,
switch_size_t  stacksize 
)

Definition at line 627 of file switch_apr.c.

Referenced by chat_thread_start(), launch_collect_thread(), launch_dispatch_threads(), speech_callback(), switch_core_launch_thread(), switch_core_memory_init(), switch_core_session_launch_thread(), switch_core_session_thread_launch(), switch_core_sqldb_start(), switch_event_fire_detailed(), switch_ivr_broadcast_in_thread(), switch_ivr_enterprise_originate(), switch_ivr_session_echo(), switch_log_init(), switch_system_thread(), switch_xml_free_in_thread(), and unicast_thread_launch().

00628 {
00629         return apr_threadattr_stacksize_set(attr, stacksize);
00630 }


Generated on Wed May 16 04:00:17 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7