D-Bus  1.9.2
Typedefs | Functions

_dbus_rmutex_lock(), etc. More...

Typedefs

typedef struct DBusRMutex DBusRMutex
 A mutex which is recursive if possible, else non-recursive. More...
 
typedef struct DBusCMutex DBusCMutex
 A mutex suitable for use with condition variables. More...
 

Functions

void _dbus_rmutex_new_at_location (DBusRMutex **location_p)
 Creates a new mutex or creates a no-op mutex if threads are not initialized. More...
 
void _dbus_cmutex_new_at_location (DBusCMutex **location_p)
 Creates a new mutex or creates a no-op mutex if threads are not initialized. More...
 
void _dbus_rmutex_free_at_location (DBusRMutex **location_p)
 Frees a DBusRMutex; does nothing if passed a NULL pointer.
 
void _dbus_cmutex_free_at_location (DBusCMutex **location_p)
 Frees a DBusCMutex; does nothing if passed a NULL pointer.
 
void _dbus_rmutex_lock (DBusRMutex *mutex)
 Locks a mutex. More...
 
void _dbus_cmutex_lock (DBusCMutex *mutex)
 Locks a mutex. More...
 
void _dbus_rmutex_unlock (DBusRMutex *mutex)
 Unlocks a mutex. More...
 
void _dbus_cmutex_unlock (DBusCMutex *mutex)
 Unlocks a mutex. More...
 
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. More...
 
void _dbus_condvar_new_at_location (DBusCondVar **location_p)
 This does the same thing as _dbus_condvar_new. More...
 
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 condition variable; does nothing if passed a NULL pointer.
 
void _dbus_condvar_wait (DBusCondVar *cond, DBusCMutex *mutex)
 Atomically unlocks the mutex and waits for the conditions variable to be signalled. More...
 
dbus_bool_t _dbus_condvar_wait_timeout (DBusCondVar *cond, DBusCMutex *mutex, int timeout_milliseconds)
 Atomically unlocks the mutex and waits for the conditions variable to be signalled, or for a timeout. More...
 
void _dbus_condvar_wake_one (DBusCondVar *cond)
 If there are threads waiting on the condition variable, wake up exactly one. More...
 
dbus_bool_t _dbus_lock (DBusGlobalLock lock)
 
void _dbus_unlock (DBusGlobalLock lock)
 

Detailed Description

_dbus_rmutex_lock(), etc.

Functions and macros related to threads and thread locks.

Typedef Documentation

typedef struct DBusCMutex DBusCMutex

A mutex suitable for use with condition variables.

This is typically non-recursive.

Definition at line 45 of file dbus-threads-internal.h.

typedef struct DBusRMutex DBusRMutex

A mutex which is recursive if possible, else non-recursive.

This is typically recursive, but that cannot be relied upon.

Definition at line 39 of file dbus-threads-internal.h.

Function Documentation

void _dbus_cmutex_lock ( DBusCMutex mutex)

Locks a mutex.

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

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

References NULL.

void _dbus_cmutex_new_at_location ( DBusCMutex **  location_p)

Creates a new mutex or creates a no-op mutex if threads are not initialized.

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

The returned mutex is suitable for use with condition variables.

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

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

References _dbus_assert, dbus_threads_init_default(), and NULL.

Referenced by _dbus_connection_new_for_transport().

void _dbus_cmutex_unlock ( DBusCMutex mutex)

Unlocks a mutex.

Does nothing if passed a NULL pointer.

Returns
TRUE on success

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

References NULL.

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 181 of file dbus-threads.c.

References dbus_threads_init_default(), and NULL.

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 used to be useful.

Returns
the location of a new condvar or NULL on OOM

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

References _dbus_assert, _dbus_condvar_new(), and NULL.

Referenced by _dbus_connection_new_for_transport().

void _dbus_condvar_wait ( DBusCondVar cond,
DBusCMutex 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 240 of file dbus-threads.c.

References NULL.

dbus_bool_t _dbus_condvar_wait_timeout ( DBusCondVar cond,
DBusCMutex 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
condthe condition variable
mutexthe mutex
timeout_millisecondsthe maximum time to wait
Returns
FALSE if the timeout occurred, TRUE if not

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

References NULL, and TRUE.

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 278 of file dbus-threads.c.

References NULL.

void _dbus_rmutex_lock ( DBusRMutex mutex)

Locks a mutex.

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

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

References NULL.

void _dbus_rmutex_new_at_location ( DBusRMutex **  location_p)

Creates a new mutex or creates a no-op mutex if threads are not initialized.

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

If possible, the mutex returned by this function is recursive, to avoid deadlocks. However, that cannot be relied on.

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

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

References _dbus_assert, dbus_threads_init_default(), and NULL.

Referenced by _dbus_connection_new_for_transport(), and _dbus_server_init_base().

void _dbus_rmutex_unlock ( DBusRMutex mutex)

Unlocks a mutex.

Does nothing if passed a NULL pointer.

Returns
TRUE on success

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

References NULL.

Referenced by _dbus_connection_unlock().