Asterisk - The Open Source Telephony Project
18.5.0
|
Definitions to aid in the use of thread local storage. More...
Go to the source code of this file.
Data Structures | |
struct | ast_threadstorage |
data for a thread locally stored variable More... | |
Macros | |
#define | AST_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT |
#define | AST_THREADSTORAGE(name) AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr, static) |
Define a thread storage variable. More... | |
#define | AST_THREADSTORAGE_CUSTOM(a, b, c) AST_THREADSTORAGE_CUSTOM_SCOPE(a,b,c,static) |
Define a thread storage variable, with custom initialization and cleanup. More... | |
#define | AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) |
#define | AST_THREADSTORAGE_EXTERNAL(name) extern struct ast_threadstorage name |
#define | AST_THREADSTORAGE_PUBLIC(name) AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr,) |
#define | AST_THREADSTORAGE_RAW(name) AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, THREADSTORAGE_RAW_CLEANUP,) |
#define | THREADSTORAGE_RAW_CLEANUP NULL |
Functions | |
void * | ast_threadstorage_get (struct ast_threadstorage *ts, size_t init_size) |
Retrieve thread storage. More... | |
void * | ast_threadstorage_get_ptr (struct ast_threadstorage *ts) |
Retrieve a raw pointer from threadstorage. More... | |
int | ast_threadstorage_set_ptr (struct ast_threadstorage *ts, void *ptr) |
Set a raw pointer from threadstorage. More... | |
Definitions to aid in the use of thread local storage.
Definition in file threadstorage.h.
#define AST_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT |
Definition at line 114 of file threadstorage.h.
#define AST_THREADSTORAGE | ( | name | ) | AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr, static) |
Define a thread storage variable.
name | The name of the thread storage object |
This macro would be used to declare an instance of thread storage in a file.
Example usage:
Definition at line 84 of file threadstorage.h.
Referenced by ao2_container_unregister().
Define a thread storage variable, with custom initialization and cleanup.
a | The name of the thread storage object |
b | This is a custom function that will be called after each thread specific object is allocated, with the allocated block of memory passed as the argument. |
c | This is a custom function that will be called instead of ast_free when the thread goes away. Note that if this is used, it MUST call free on the allocated memory. |
Example usage:
Definition at line 109 of file threadstorage.h.
#define AST_THREADSTORAGE_CUSTOM_SCOPE | ( | name, | |
c_init, | |||
c_cleanup, | |||
scope | |||
) |
Definition at line 118 of file threadstorage.h.
#define AST_THREADSTORAGE_EXTERNAL | ( | name | ) | extern struct ast_threadstorage name |
Definition at line 88 of file threadstorage.h.
#define AST_THREADSTORAGE_PUBLIC | ( | name | ) | AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr,) |
Definition at line 86 of file threadstorage.h.
#define AST_THREADSTORAGE_RAW | ( | name | ) | AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, THREADSTORAGE_RAW_CLEANUP,) |
Definition at line 90 of file threadstorage.h.
#define THREADSTORAGE_RAW_CLEANUP NULL |
Definition at line 69 of file threadstorage.h.
|
inline |
Retrieve thread storage.
ts | This is a pointer to the thread storage structure declared by using the AST_THREADSTORAGE macro. If declared with AST_THREADSTORAGE(my_buf), then this argument would be (&my_buf). |
init_size | This is the amount of space to be allocated the first time this thread requests its data. Thus, this should be the size that the code accessing this thread storage is assuming the size to be. |
Example usage:
Definition at line 197 of file threadstorage.h.
References ast_calloc, ast_free, AST_INLINE_API, ast_threadstorage_get_ptr(), buf, ast_threadstorage::custom_init, make_ari_stubs::file, ast_threadstorage::key, ast_threadstorage::key_init, NULL, and ast_threadstorage::once.
Referenced by __ast_frdup(), __frame_free(), acf_curl_helper(), ast_callid_threadassoc_add(), ast_callid_threadassoc_change(), ast_callid_threadassoc_remove(), ast_channel_internal_errno(), ast_channel_internal_errno_set(), ast_find_lock_info(), ast_frame_header_new(), ast_inet_ntoa(), ast_mark_lock_acquired(), ast_mark_lock_failed(), ast_read_threadstorage_callid(), ast_remove_lock_info(), ast_restore_lock_info(), ast_sched_del(), ast_sip_thread_is_servant(), ast_state2str(), ast_store_lock_info(), ast_suspend_lock_info(), ast_term_color(), ast_thread_inhibit_escalations(), ast_thread_inhibit_escalations_swap(), ast_thread_is_user_interface(), ast_thread_user_interface_set(), ast_verb_console_get(), ast_verb_console_register(), ast_verb_console_set(), ast_verb_console_unregister(), callstate2str(), chan_pjsip_get_uniqueid(), console_print(), control2str(), device2str(), dialplan_handle_msg_cb(), dummy_start(), find_or_create_temporary_state(), find_temporary_state(), get_auth(), get_transport_list(), iax_frame_free(), iax_frame_new(), idle_sched_init_pj_thread(), is_passthru_update(), pj_thread_register_check(), process_text_line(), registration_client_send(), remove_auth(), remove_temporary_state(), set_passthru_update(), sip_outbound_registration_response_cb(), sip_thread_start(), ssl_error_to_string(), store_auth(), substate2str(), thread_inhibits_escalations(), and transmit_response_using_temp().
|
inline |
Retrieve a raw pointer from threadstorage.
ts | Threadstorage object to operate on. |
Definition at line 241 of file threadstorage.h.
References ast_threadstorage::key, ast_threadstorage::key_init, and ast_threadstorage::once.
Referenced by __ast_trace(), _ast_trace_dec_indent(), _ast_trace_get_indent(), _ast_trace_inc_indent(), ast_channel_get_intercept_mode(), ast_cli_completion_add(), ast_cli_completion_vector(), ast_log_safe(), ast_threadpool_serializer_get_current(), and ast_threadstorage_get().
|
inline |
Set a raw pointer from threadstorage.
ts | Threadstorage object to operate on. |
0 | Success |
non-zero | Failure |
Definition at line 260 of file threadstorage.h.
Referenced by __ast_trace(), _ast_trace_dec_indent(), _ast_trace_inc_indent(), _ast_trace_set_indent(), ast_cli_completion_vector(), ast_log_safe(), channel_set_intercept_mode(), cli_completion_vector_add(), and execute_tasks().