Added locking primitive lazy_mutex, which has essentially the same behaviour
as a mutex, but allocates its semaphore lazily. This comes at the cost of an additional atomic_add() when the semaphore has actually to be acquired, but saves the semaphore creation completely in single-threaded programs and in any program when there's no lock contention. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34339 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,6 +22,19 @@ status_t mutex_lock(mutex *lock);
|
||||
void mutex_unlock(mutex *lock);
|
||||
|
||||
|
||||
typedef struct lazy_mutex {
|
||||
int32 benaphore;
|
||||
sem_id semaphore;
|
||||
const char* name;
|
||||
} lazy_mutex;
|
||||
|
||||
status_t lazy_mutex_init(lazy_mutex *lock, const char *name);
|
||||
// name will not be cloned and must rename valid
|
||||
void lazy_mutex_destroy(mutex *lock);
|
||||
status_t lazy_mutex_lock(lazy_mutex *lock);
|
||||
void lazy_mutex_unlock(lazy_mutex *lock);
|
||||
|
||||
|
||||
typedef struct rw_lock {
|
||||
const char * name;
|
||||
mutex lock;
|
||||
|
||||
Reference in New Issue
Block a user