|
Geogram Version 1.10.2
A programming library of geometric algorithms
|
An array of light-weight synchronisation primitives (spinlocks). More...
#include <geogram/basic/thread_sync.h>
Public Member Functions | |
| CompactSpinLockArray () | |
| Constructs a new SpinLockArray of size 0. | |
| CompactSpinLockArray (index_t size_in) | |
Constructs a new CompactSpinLockArray of size size_in. | |
| ~CompactSpinLockArray () | |
| CompactSpinLockArray destructor. | |
| CompactSpinLockArray (const CompactSpinLockArray &rhs)=delete | |
| Forbids copy. | |
| CompactSpinLockArray & | operator= (const CompactSpinLockArray &rhs)=delete |
| Forbids copy. | |
| void | resize (index_t size_in) |
| Resizes a CompactSpinLockArray. | |
| index_t | size () const |
| Gets the number of spinlocks in this array. | |
| void | clear () |
| Resets size to 0 and clears all the memory. | |
| void | acquire_spinlock (index_t i) |
| Acquires a spinlock at a given index. | |
| void | release_spinlock (index_t i) |
| Releases a spinlock at a given index. | |
An array of light-weight synchronisation primitives (spinlocks).
In this implementation, storage is optimized so that a single bit per spinlock is used. This implementation uses std::atomic<uint32_t>
Definition at line 301 of file thread_sync.h.
|
inline |
Constructs a new SpinLockArray of size 0.
Definition at line 306 of file thread_sync.h.
|
inline |
Constructs a new CompactSpinLockArray of size size_in.
| [in] | size_in | number of spinlocks in the array. |
Definition at line 313 of file thread_sync.h.
|
inline |
CompactSpinLockArray destructor.
Definition at line 320 of file thread_sync.h.
|
inline |
Acquires a spinlock at a given index.
Loops until spinlock at index i is available then reserve it.
| [in] | i | index of the spinlock |
Definition at line 378 of file thread_sync.h.
|
inline |
Resets size to 0 and clears all the memory.
Definition at line 367 of file thread_sync.h.
|
inline |
Releases a spinlock at a given index.
Makes spinlock at index i available to other threads.
| [in] | i | index of the spinlock |
Definition at line 397 of file thread_sync.h.
|
inline |
Resizes a CompactSpinLockArray.
All the spinlocks are reset to 0.
| [in] | size_in | The desired new size. |
Definition at line 341 of file thread_sync.h.
|
inline |
Gets the number of spinlocks in this array.
Definition at line 360 of file thread_sync.h.