|
mUPnP for C
|
Data Structures | |
| struct | _mUpnpMutex |
| The generic wrapper struct for mUPnP's mutexes. More... | |
Typedefs | |
| typedef struct _mUpnpMutex | mUpnpMutex |
| The generic wrapper struct for mUPnP's mutexes. | |
Functions | |
| mUpnpMutex * | mupnp_mutex_new (void) |
| Create a new mutex for synchronization. | |
| bool | mupnp_mutex_delete (mUpnpMutex *mutex) |
| Destroy a mutex and free resources. | |
| bool | mupnp_mutex_lock (mUpnpMutex *mutex) |
| Acquire a mutex lock (blocking) | |
| bool | mupnp_mutex_unlock (mUpnpMutex *mutex) |
| Release a previously acquired mutex lock. | |
| typedef struct _mUpnpMutex mUpnpMutex |
The generic wrapper struct for mUPnP's mutexes.
This wrapper has been created to enable 100% code compatibility for different platforms (Linux, Win32 etc..)
| bool mupnp_mutex_delete | ( | mUpnpMutex * | mutex | ) |
Destroy a mutex and free resources.
Releases all resources associated with the mutex. The mutex must be unlocked before calling this function.
| mutex | The mutex to destroy. May be NULL (no-op if NULL). |
| true | Successfully destroyed the mutex |
| false | Failed to destroy (e.g., mutex is NULL or still locked) |
| bool mupnp_mutex_lock | ( | mUpnpMutex * | mutex | ) |
Acquire a mutex lock (blocking)
Attempts to lock the mutex. If the mutex is already locked by another thread, this function blocks (waits) until the mutex becomes available.
After successfully locking, the calling thread has exclusive access to the protected resource until mupnp_mutex_unlock() is called.
Mutexes are not recursive on all platforms. Attempting to lock the same mutex twice from the same thread may cause deadlock.
When WITH_THREAD_LOCK_TRACE is defined, this is replaced with a macro that enables lock tracing for debugging deadlocks and lock contention.
| mutex | The mutex to lock. Must not be NULL. |
| true | Successfully acquired the lock |
| false | Failed to acquire lock (mutex is NULL or system error) |
| mUpnpMutex * mupnp_mutex_new | ( | void | ) |
Create a new mutex for synchronization.
Allocates and initializes a platform-independent mutex object. Mutexes are used to protect shared resources and ensure thread-safe access to data structures across the mUPnP library.
The mutex is initially unlocked and ready to use.
Platform support:
| bool mupnp_mutex_unlock | ( | mUpnpMutex * | mutex | ) |
Release a previously acquired mutex lock.
Unlocks a mutex that was previously locked with mupnp_mutex_lock(). This allows other threads waiting on the mutex to acquire the lock.
The mutex must be locked by the calling thread before calling this function. Unlocking a mutex that is not locked or is locked by a different thread results in undefined behavior.
When WITH_THREAD_LOCK_TRACE is defined, this is replaced with a macro that enables lock tracing for debugging.
| mutex | The mutex to unlock. Must not be NULL and must be locked by the calling thread. |
| true | Successfully released the lock |
| false | Failed to unlock (mutex is NULL, not locked, or system error) |