MPD  0.20.18
Data Structures | Functions | Variables
DatabaseLock.hxx File Reference

Support for locking data structures from the database, for safe multi-threading. More...

#include "check.h"
#include "thread/Mutex.hxx"
#include "Compiler.h"
#include <assert.h>
#include "thread/Id.hxx"
Include dependency graph for DatabaseLock.hxx:

Go to the source code of this file.

Data Structures

class  ScopeDatabaseLock
 
class  ScopeDatabaseUnlock
 Unlock the database while in the current scope. More...
 

Functions

static gcc_pure bool holding_db_lock () noexcept
 Does the current thread hold the database lock? More...
 
static void db_lock (void)
 Obtain the global database lock. More...
 
static void db_unlock (void)
 Release the global database lock. More...
 

Variables

Mutex db_mutex
 
ThreadId db_mutex_holder
 

Detailed Description

Support for locking data structures from the database, for safe multi-threading.

Definition in file DatabaseLock.hxx.

Function Documentation

◆ db_lock()

static void db_lock ( void  )
inlinestatic

Obtain the global database lock.

This is needed before dereferencing a #song or #directory. It is not recursive.

Definition at line 60 of file DatabaseLock.hxx.

◆ db_unlock()

static void db_unlock ( void  )
inlinestatic

Release the global database lock.

Definition at line 76 of file DatabaseLock.hxx.

◆ holding_db_lock()

static gcc_pure bool holding_db_lock ( )
inlinestaticnoexcept

Does the current thread hold the database lock?

Definition at line 48 of file DatabaseLock.hxx.

Variable Documentation

◆ db_mutex

Mutex db_mutex

◆ db_mutex_holder

ThreadId db_mutex_holder