Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GEO::Process::BasicSpinLockArray Class Reference

An array of light-weight synchronisation primitives (spinlocks). More...

#include <geogram/basic/thread_sync.h>

Public Member Functions

 BasicSpinLockArray ()
 Constructs a new BasicSpinLockArray of size 0.
 
 BasicSpinLockArray (index_t size_in)
 Constructs a new BasicSpinLockArray of size size_in. More...
 
 BasicSpinLockArray (const BasicSpinLockArray &rhs)=delete
 Forbids copy.
 
BasicSpinLockArrayoperator= (const BasicSpinLockArray &rhs)=delete
 Forbids copy.
 
void resize (index_t size_in)
 Resizes a BasicSpinLockArray. More...
 
void clear ()
 Resets size to 0 and clears all the memory.
 
index_t size () const
 Gets the number of spinlocks in this array.
 
void acquire_spinlock (index_t i)
 Acquires a spinlock at a given index. More...
 
void release_spinlock (index_t i)
 Releases a spinlock at a given index. More...
 

Detailed Description

An array of light-weight synchronisation primitives (spinlocks).

This is the reference implementation, that uses an array of spinlock. There is also a more memory-efficient implementation, CompactSpinLockArray, to be used for a very large number of spinlocks.

See also
acquire_spinlock(), release_spinlock()

Definition at line 197 of file thread_sync.h.

Constructor & Destructor Documentation

◆ BasicSpinLockArray()

GEO::Process::BasicSpinLockArray::BasicSpinLockArray ( index_t  size_in)
inline

Constructs a new BasicSpinLockArray of size size_in.

Parameters
[in]size_innumber of spinlocks in the array.

Definition at line 209 of file thread_sync.h.

Member Function Documentation

◆ acquire_spinlock()

void GEO::Process::BasicSpinLockArray::acquire_spinlock ( index_t  i)
inline

Acquires a spinlock at a given index.

Loops until spinlock at index i is available then reserve it.

Parameters
[in]iindex of the spinlock

Definition at line 262 of file thread_sync.h.

◆ release_spinlock()

void GEO::Process::BasicSpinLockArray::release_spinlock ( index_t  i)
inline

Releases a spinlock at a given index.

Makes spinlock at index i available to other threads.

Parameters
[in]iindex of the spinlock

Definition at line 272 of file thread_sync.h.

◆ resize()

void GEO::Process::BasicSpinLockArray::resize ( index_t  size_in)
inline

Resizes a BasicSpinLockArray.

All the spinlocks are reset to 0.

Parameters
[in]size_inThe desired new size.

Definition at line 230 of file thread_sync.h.


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