Thread functions
[D-Bus secret internal implementation details]

_dbus_mutex_lock(), etc. More...

Functions

DBusMutex_dbus_mutex_new (void)
 Creates a new mutex using the function supplied to dbus_threads_init(), or creates a no-op mutex if threads are not initialized.
void _dbus_mutex_new_at_location (DBusMutex **location_p)
 This does the same thing as _dbus_mutex_new.
void _dbus_mutex_free (DBusMutex *mutex)
 Frees a mutex created with dbus_mutex_new(); does nothing if passed a NULL pointer.
void _dbus_mutex_free_at_location (DBusMutex **location_p)
 Frees a mutex and removes it from the uninitialized_mutex_list; does nothing if passed a NULL pointer.
void _dbus_mutex_lock (DBusMutex *mutex)
 Locks a mutex.
void _dbus_mutex_unlock (DBusMutex *mutex)
 Unlocks a mutex.
DBusCondVar_dbus_condvar_new (void)
 Creates a new condition variable using the function supplied to dbus_threads_init(), or creates a no-op condition variable if threads are not initialized.
void _dbus_condvar_new_at_location (DBusCondVar **location_p)
 This does the same thing as _dbus_condvar_new.
void _dbus_condvar_free (DBusCondVar *cond)
 Frees a conditional variable created with dbus_condvar_new(); does nothing if passed a NULL pointer.
void _dbus_condvar_free_at_location (DBusCondVar **location_p)
 Frees a conditional variable and removes it from the uninitialized_condvar_list; does nothing if passed a NULL pointer.
void _dbus_condvar_wait (DBusCondVar *cond, DBusMutex *mutex)
 Atomically unlocks the mutex and waits for the conditions variable to be signalled.
dbus_bool_t _dbus_condvar_wait_timeout (DBusCondVar *cond, DBusMutex *mutex, int timeout_milliseconds)
 Atomically unlocks the mutex and waits for the conditions variable to be signalled, or for a timeout.
void _dbus_condvar_wake_one (DBusCondVar *cond)
 If there are threads waiting on the condition variable, wake up exactly one.
void _dbus_condvar_wake_all (DBusCondVar *cond)
 If there are threads waiting on the condition variable, wake up all of them.

Detailed Description

_dbus_mutex_lock(), etc.

Functions and macros related to threads and thread locks.


Function Documentation

DBusCondVar* _dbus_condvar_new ( void   ) 

Creates a new condition variable using the function supplied to dbus_threads_init(), or creates a no-op condition variable if threads are not initialized.

May return NULL even if threads are initialized, indicating out-of-memory.

Returns:
new mutex or NULL

Definition at line 180 of file dbus-threads.c.

References DBusThreadFunctions::condvar_new.

Referenced by _dbus_condvar_new_at_location().

void _dbus_condvar_new_at_location ( DBusCondVar **  location_p  ) 

This does the same thing as _dbus_condvar_new.

It however gives another level of indirection by allocating a pointer to point to the condvar location. This allows the threading module to swap out dummy condvars for real a real condvar so libraries can initialize threads even after the D-Bus API has been used.

Returns:
the location of a new condvar or NULL on OOM

Definition at line 200 of file dbus-threads.c.

References _dbus_condvar_free(), _dbus_condvar_new(), _dbus_current_generation, _dbus_list_append(), and NULL.

Referenced by _dbus_connection_new_for_transport().

void _dbus_condvar_wait ( DBusCondVar cond,
DBusMutex mutex 
)

Atomically unlocks the mutex and waits for the conditions variable to be signalled.

Locks the mutex again before returning. Does nothing if passed a NULL pointer.

Definition at line 250 of file dbus-threads.c.

References DBusThreadFunctions::condvar_wait.

dbus_bool_t _dbus_condvar_wait_timeout ( DBusCondVar cond,
DBusMutex mutex,
int  timeout_milliseconds 
)

Atomically unlocks the mutex and waits for the conditions variable to be signalled, or for a timeout.

Locks the mutex again before returning. Does nothing if passed a NULL pointer. Return value is FALSE if we timed out, TRUE otherwise.

Parameters:
cond the condition variable
mutex the mutex
timeout_milliseconds the maximum time to wait
Returns:
FALSE if the timeout occurred, TRUE if not

Definition at line 269 of file dbus-threads.c.

References DBusThreadFunctions::condvar_wait, DBusThreadFunctions::condvar_wait_timeout, and TRUE.

void _dbus_condvar_wake_all ( DBusCondVar cond  ) 

If there are threads waiting on the condition variable, wake up all of them.

Does nothing if passed a NULL pointer.

Definition at line 297 of file dbus-threads.c.

References DBusThreadFunctions::condvar_wake_all.

void _dbus_condvar_wake_one ( DBusCondVar cond  ) 

If there are threads waiting on the condition variable, wake up exactly one.

Does nothing if passed a NULL pointer.

Definition at line 285 of file dbus-threads.c.

References DBusThreadFunctions::condvar_wake_one.

void _dbus_mutex_lock ( DBusMutex mutex  ) 

Locks a mutex.

Does nothing if passed a NULL pointer. Locks may be recursive if threading implementation initialized recursive locks.

Definition at line 143 of file dbus-threads.c.

References DBusThreadFunctions::mutex_lock, and DBusThreadFunctions::recursive_mutex_lock.

Referenced by _dbus_data_slot_allocator_alloc(), _dbus_data_slot_allocator_free(), _dbus_data_slot_list_get(), and _dbus_data_slot_list_set().

DBusMutex* _dbus_mutex_new ( void   ) 

Creates a new mutex using the function supplied to dbus_threads_init(), or creates a no-op mutex if threads are not initialized.

May return NULL even if threads are initialized, indicating out-of-memory.

Returns:
new mutex or NULL

Definition at line 68 of file dbus-threads.c.

References DBusThreadFunctions::mutex_new, and DBusThreadFunctions::recursive_mutex_new.

Referenced by _dbus_mutex_new_at_location().

void _dbus_mutex_new_at_location ( DBusMutex **  location_p  ) 

This does the same thing as _dbus_mutex_new.

It however gives another level of indirection by allocating a pointer to point to the mutex location. This allows the threading module to swap out dummy mutexes for real a real mutex so libraries can initialize threads even after the D-Bus API has been used.

Parameters:
location_p the location of the new mutex, can return NULL on OOM

Definition at line 88 of file dbus-threads.c.

References _dbus_assert, _dbus_current_generation, _dbus_list_append(), _dbus_mutex_free(), _dbus_mutex_new(), and NULL.

Referenced by _dbus_connection_new_for_transport(), and _dbus_server_init_base().

void _dbus_mutex_unlock ( DBusMutex mutex  ) 

Unlocks a mutex.

Does nothing if passed a NULL pointer.

Returns:
TRUE on success

Definition at line 160 of file dbus-threads.c.

References DBusThreadFunctions::mutex_unlock, and DBusThreadFunctions::recursive_mutex_unlock.

Referenced by _dbus_data_slot_allocator_alloc(), _dbus_data_slot_allocator_free(), _dbus_data_slot_list_get(), and _dbus_data_slot_list_set().


Generated on Tue Feb 24 16:40:41 2009 for D-Bus by  doxygen 1.5.1