www.delorie.com/gnu/docs/libtool/libtool_48.html   search  
 
Buy GNU books!


Libtool

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.3 Using libtldl in a multi threaded environment

Using the lt_dlmutex_register() function, and by providing some appropriate callback function definitions, libltdl can be used in a multi-threaded environment.

Type: void lt_dlmutex_lock (void)
This is the type of a function pointer holding the address of a function which will be called at the start of parts of the libltdl implementation code which require a mutex lock.

Because libltdl is inherantly recursive, it is important that the locking mechanism employed by these callback functions are reentrant, or else strange problems will occur.

Type: void lt_dlmutex_unlock (void)
The type of a matching unlock function.

Type: void lt_dlmutex_seterror (const char *error);
Many of the functions in the libltdl API have a special return value to indicate to the client that an error has occured. Normally (in single threaded applications) a string describing that error can be retrieved from internal storage with lt_dlerror().

A function of this type must be registered with the library in order for it to work in a multi-threaded context. The function should store any error message passed in thread local storage.

Type: const char * lt_dlmutex_geterror (void)
The type of a matching callback function to retrieve the last stored error message from thread local storage.

When regeistered correctly this function will be used by lt_dlerror()) from all threads to retrieve error messages for the client.

Function: int lt_dlmutex_register (lt_dlmutex_lock *lock, lt_dlmutex_unlock *unlock, lt_dlmutex_set_error *seterror, lt_dlmutex_geterror *geterror)
Use this function to register one of each of function ttypes described above in preparation for multi-threaded use of libltdl. All arguments must be valid non-NULL function addresses, or else all NULL to return to single threaded operation.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003