Asterisk - The Open Source Telephony Project GIT-master-77d630f
Functions
serializer_shutdown_group.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct ast_serializer_shutdown_groupast_serializer_shutdown_group_alloc (void)
 Create a serializer group shutdown control object. More...
 
void ast_serializer_shutdown_group_dec (struct ast_serializer_shutdown_group *shutdown_group)
 Decrement the number of serializer members in the group. More...
 
void ast_serializer_shutdown_group_inc (struct ast_serializer_shutdown_group *shutdown_group)
 Increment the number of serializer members in the group. More...
 
int ast_serializer_shutdown_group_join (struct ast_serializer_shutdown_group *shutdown_group, int timeout)
 Wait for the serializers in the group to shutdown with timeout. More...
 

Function Documentation

◆ ast_serializer_shutdown_group_alloc()

struct ast_serializer_shutdown_group * ast_serializer_shutdown_group_alloc ( void  )

Create a serializer group shutdown control object.

Since
13.5.0
Returns
ao2 object to control shutdown of a serializer group.

Definition at line 42 of file serializer_shutdown_group.c.

43{
45
47 if (!shutdown_group) {
48 return NULL;
49 }
51 return shutdown_group;
52}
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
#define ast_cond_init(cond, attr)
Definition: lock.h:208
static struct ast_serializer_shutdown_group * shutdown_group
Shutdown group for options serializers.
#define NULL
Definition: resample.c:96
static void serializer_shutdown_group_dtor(void *vdoomed)

References ao2_alloc, ast_cond_init, ast_serializer_shutdown_group::cond, NULL, serializer_shutdown_group_dtor(), and shutdown_group.

Referenced by ast_serializer_pool_create(), ast_serializer_taskpool_create(), load_module(), and sip_options_init_task().

◆ ast_serializer_shutdown_group_dec()

void ast_serializer_shutdown_group_dec ( struct ast_serializer_shutdown_group shutdown_group)

Decrement the number of serializer members in the group.

Since
23.1.0
22.7.0
20.17.0
Parameters
shutdown_groupGroup shutdown controller.

Definition at line 100 of file serializer_shutdown_group.c.

101{
104 if (!shutdown_group->count) {
106 }
108}
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
#define ast_cond_signal(cond)
Definition: lock.h:210

References ao2_lock, ao2_unlock, ast_cond_signal, ast_serializer_shutdown_group::cond, ast_serializer_shutdown_group::count, and shutdown_group.

Referenced by serializer_shutdown().

◆ ast_serializer_shutdown_group_inc()

void ast_serializer_shutdown_group_inc ( struct ast_serializer_shutdown_group shutdown_group)

Increment the number of serializer members in the group.

Since
23.1.0
22.7.0
20.17.0
Parameters
shutdown_groupGroup shutdown controller.

Definition at line 93 of file serializer_shutdown_group.c.

References ao2_lock, ao2_unlock, ast_serializer_shutdown_group::count, and shutdown_group.

Referenced by ast_taskpool_serializer_group(), and ast_threadpool_serializer_group().

◆ ast_serializer_shutdown_group_join()

int ast_serializer_shutdown_group_join ( struct ast_serializer_shutdown_group shutdown_group,
int  timeout 
)

Wait for the serializers in the group to shutdown with timeout.

Since
13.5.0
Parameters
shutdown_groupGroup shutdown controller. (Returns 0 immediately if NULL)
timeoutNumber of seconds to wait for the serializers in the group to shutdown. Zero if the timeout is disabled.
Returns
Number of serializers that did not get shutdown within the timeout.

Definition at line 54 of file serializer_shutdown_group.c.

55{
56 int remaining;
58
59 if (!shutdown_group) {
60 return 0;
61 }
62
65
67 if (timeout) {
68 struct timeval start;
69 struct timespec end;
70
71 start = ast_tvnow();
72 end.tv_sec = start.tv_sec + timeout;
73 end.tv_nsec = start.tv_usec * 1000;
74 while (shutdown_group->count) {
76 /* Error or timed out waiting for the count to reach zero. */
77 break;
78 }
79 }
80 } else {
81 while (shutdown_group->count) {
83 /* Error */
84 break;
85 }
86 }
87 }
88 remaining = shutdown_group->count;
90 return remaining;
91}
ast_mutex_t lock
Definition: app_sla.c:337
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
Definition: astobj2.c:476
char * end
Definition: eagi_proxy.c:73
#define ast_cond_wait(cond, mutex)
Definition: lock.h:212
#define ast_cond_timedwait(cond, mutex, time)
Definition: lock.h:213
Structure for mutex and tracking information.
Definition: lock.h:142
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
#define ast_assert(a)
Definition: utils.h:776

References ao2_lock, ao2_object_get_lockaddr(), ao2_unlock, ast_assert, ast_cond_timedwait, ast_cond_wait, ast_tvnow(), ast_serializer_shutdown_group::cond, ast_serializer_shutdown_group::count, end, lock, NULL, and shutdown_group.

Referenced by ast_res_pjsip_cleanup_options_handling(), ast_serializer_pool_destroy(), and unload_module().