Thu Jul 9 13:41:34 2009

Asterisk developer's documentation


threadstorage.h File Reference

Definitions to aid in the use of thread local storage. More...

#include "asterisk/utils.h"
#include "asterisk/inline_api.h"

Go to the source code of this file.

Data Structures

struct  ast_threadstorage
 data for a thread locally stored variable More...

Defines

#define AST_THREADSTORAGE(name)   AST_THREADSTORAGE_CUSTOM(name, NULL, ast_free_ptr)
 Define a thread storage variable.
#define AST_THREADSTORAGE_CUSTOM(name, c_init, c_cleanup)
 Define a thread storage variable, with custom initialization and cleanup.

Functions

void * ast_threadstorage_get (struct ast_threadstorage *ts, size_t init_size)
 Retrieve thread storage.


Detailed Description

Definitions to aid in the use of thread local storage.

Author:
Russell Bryant <russell@digium.com>

Definition in file threadstorage.h.


Define Documentation

#define AST_THREADSTORAGE ( name   )     AST_THREADSTORAGE_CUSTOM(name, NULL, ast_free_ptr)

Define a thread storage variable.

This macro would be used to declare an instance of thread storage in a file.

Example usage:

Definition at line 81 of file threadstorage.h.

#define AST_THREADSTORAGE_CUSTOM ( name,
c_init,
c_cleanup   ) 

Define a thread storage variable, with custom initialization and cleanup.

Example usage:
 AST_THREADSTORAGE_CUSTOM(my_buf, my_init, my_cleanup);

Definition at line 101 of file threadstorage.h.


Function Documentation

void * ast_threadstorage_get ( struct ast_threadstorage ts,
size_t  init_size 
) [inline]

Retrieve thread storage.

Returns:
This function will return the thread local storage associated with the thread storage management variable passed as the first argument. The result will be NULL in the case of a memory allocation error.
Example usage:
 AST_THREADSTORAGE(my_buf);
 #define MY_BUF_SIZE   128
 ...
 void my_func(const char *fmt, ...)
 {
      void *buf;

      if (!(buf = ast_threadstorage_get(&my_buf, MY_BUF_SIZE)))
           return;
      ...
 }

Definition at line 179 of file threadstorage.h.

References ast_calloc, buf, and free.

Referenced by __frame_free(), ast_frame_header_new(), ast_frdup(), ast_inet_ntoa(), ast_state2str(), control2str(), curl_internal(), device2str(), dummy_start(), iax_frame_free(), iax_frame_new(), process_sdp(), and transmit_response_using_temp().

00183 {


Generated on Thu Jul 9 13:41:34 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7