D-Bus 1.15.12
Typedefs | Functions

_dbus_rmutex_lock(), etc. More...

Typedefs

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

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.
 
void _dbus_cmutex_new_at_location (DBusCMutex **location_p)
 Creates a new mutex or creates a no-op mutex if threads are not initialized.
 
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.
 
void _dbus_cmutex_lock (DBusCMutex *mutex)
 Locks a mutex.
 
void _dbus_rmutex_unlock (DBusRMutex *mutex)
 Unlocks a mutex.
 
void _dbus_cmutex_unlock (DBusCMutex *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 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.
 
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.
 
void _dbus_condvar_wake_one (DBusCondVar *cond)
 If there are threads waiting on the condition variable, wake up exactly one.
 
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

◆ DBusCMutex

typedef struct DBusCMutex DBusCMutex

A mutex suitable for use with condition variables.

This is typically non-recursive.

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

◆ DBusRMutex

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 41 of file dbus-threads-internal.h.

Function Documentation

◆ _dbus_cmutex_free_at_location()

void _dbus_cmutex_free_at_location ( DBusCMutex **  location_p)

Frees a DBusCMutex; does nothing if passed a NULL pointer.

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

References NULL.

Referenced by _dbus_connection_new_for_transport().

◆ _dbus_cmutex_lock()

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

References NULL.

◆ _dbus_cmutex_new_at_location()

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

References _dbus_assert, dbus_threads_init_default(), and NULL.

Referenced by _dbus_connection_new_for_transport().

◆ _dbus_cmutex_unlock()

void _dbus_cmutex_unlock ( DBusCMutex mutex)

Unlocks a mutex.

Does nothing if passed a NULL pointer.

Returns
TRUE on success

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

References NULL.

◆ _dbus_condvar_free()

void _dbus_condvar_free ( DBusCondVar cond)

Frees a conditional variable created with dbus_condvar_new(); does nothing if passed a NULL pointer.

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

References NULL.

◆ _dbus_condvar_free_at_location()

void _dbus_condvar_free_at_location ( DBusCondVar **  location_p)

Frees a condition variable; does nothing if passed a NULL pointer.

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

References NULL.

Referenced by _dbus_connection_new_for_transport().

◆ _dbus_condvar_new()

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

References dbus_threads_init_default(), and NULL.

Referenced by _dbus_condvar_new_at_location().

◆ _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 202 of file dbus-threads.c.

References _dbus_assert, _dbus_condvar_new(), and NULL.

Referenced by _dbus_connection_new_for_transport().

◆ _dbus_condvar_wait()

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

References NULL.

◆ _dbus_condvar_wait_timeout()

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

References NULL, and TRUE.

◆ _dbus_condvar_wake_one()

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

References NULL.

◆ _dbus_lock()

dbus_bool_t _dbus_lock ( DBusGlobalLock  lock)

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

◆ _dbus_rmutex_free_at_location()

void _dbus_rmutex_free_at_location ( DBusRMutex **  location_p)

Frees a DBusRMutex; does nothing if passed a NULL pointer.

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

References NULL.

Referenced by _dbus_connection_new_for_transport(), _dbus_counter_unref(), _dbus_server_finalize_base(), and _dbus_server_init_base().

◆ _dbus_rmutex_lock()

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

References NULL.

Referenced by _dbus_counter_adjust_size(), _dbus_counter_adjust_unix_fd(), _dbus_counter_get_size_value(), _dbus_counter_get_unix_fd_value(), _dbus_counter_notify(), _dbus_counter_ref(), _dbus_counter_set_notify(), and _dbus_counter_unref().

◆ _dbus_rmutex_new_at_location()

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

References _dbus_assert, dbus_threads_init_default(), and NULL.

Referenced by _dbus_connection_new_for_transport(), _dbus_counter_new(), and _dbus_server_init_base().

◆ _dbus_rmutex_unlock()

void _dbus_rmutex_unlock ( DBusRMutex mutex)

◆ _dbus_unlock()

void _dbus_unlock ( DBusGlobalLock  lock)

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