Zero  0.1.0
Public Member Functions | Private Member Functions | List of all members
tatas_lock Struct Reference

A test-and-test-and-set spinlock. More...

#include <tatas.h>

Public Member Functions

 tatas_lock ()
 
bool try_lock ()
 Try to acquire the lock immediately. More...
 
void acquire ()
 Acquire the lock, spinning as long as necessary. More...
 
void release ()
 Release the lock. More...
 
bool is_mine () const
 True if this thread is the lock holder. More...
 

Private Member Functions

void spin ()
 spin until lock is free More...
 

Detailed Description

A test-and-test-and-set spinlock.

This lock is good for short, uncontended critical sections. If contention is high, use an mcs_lock. Long critical sections should use pthread_mutex_t.

Tradeoffs are:

See also
REFSYNC

Constructor & Destructor Documentation

§ tatas_lock()

tatas_lock::tatas_lock ( )
inline

skip

Member Function Documentation

§ acquire()

void tatas_lock::acquire ( )
inline

Acquire the lock, spinning as long as necessary.

§ is_mine()

bool tatas_lock::is_mine ( ) const
inline

True if this thread is the lock holder.

§ release()

void tatas_lock::release ( )
inline

Release the lock.

§ spin()

void tatas_lock::spin ( )
inlineprivate

spin until lock is free

§ try_lock()

bool tatas_lock::try_lock ( )
inline

Try to acquire the lock immediately.


The documentation for this struct was generated from the following file: