Geogram  Version 1.9.0
A programming library of geometric algorithms
GEO::CellStatusArray Class Reference

An array of cell status codes associates to each tetrahedron in a Delaunay tetrahedralization. More...

#include <geogram/delaunay/delaunay_sync.h>

Public Types

typedef uint8_t cell_status_t
 

Public Member Functions

 CellStatusArray ()
 Creates an empty CellStatusArray.
 
 CellStatusArray (index_t size_in)
 Creates a CellStatusArray. More...
 
 ~CellStatusArray ()
 CellStatusArray destructor. More...
 
 CellStatusArray (const CellStatusArray &rhs)=delete
 Forbids copy.
 
CellStatusArrayoperator= (const CellStatusArray &rhs)=delete
 Forbids copy.
 
cell_status_t acquire_cell (index_t cell, cell_status_t status)
 Tentatively acquires a cell. More...
 
void release_cell (index_t cell)
 Releases a cell. More...
 
cell_status_t cell_thread (index_t cell) const
 Gets the thread that acquired a cell. More...
 
bool cell_is_marked_as_conflict (index_t cell) const
 Tests whether a cell is marked as conflict. More...
 
void mark_cell_as_conflict (index_t cell)
 Marks a cell as conflict. More...
 
void set_cell_status (index_t cell, cell_status_t status)
 Sets the status of a cell. More...
 
void resize (index_t size_in, index_t capacity_in)
 Resizes this CellStatusArray. More...
 
void resize (index_t size_in)
 Resizes this CellStatusArray. More...
 
void reserve (index_t new_capacity)
 Reserves additional space. More...
 
void grow ()
 Increases the size of the array for one additional element. More...
 
index_t size () const
 Gets the size of this CellStatusArray. More...
 
void clear ()
 Clears this CellStatusArray. More...
 

Static Public Attributes

static constexpr cell_status_t FREE_CELL = 127
 
static constexpr cell_status_t THREAD_MASK = 127
 
static constexpr cell_status_t CONFLICT_MASK = 128
 

Detailed Description

An array of cell status codes associates to each tetrahedron in a Delaunay tetrahedralization.

Each item can be atomically accessed to implement fine-grained resource control in a multithreaded context. It is used to memorize for each tetrahedron the thread that owns it as well as a couple of flags.

Definition at line 62 of file delaunay_sync.h.

Constructor & Destructor Documentation

◆ CellStatusArray()

GEO::CellStatusArray::CellStatusArray ( index_t  size_in)
inline

Creates a CellStatusArray.

Parameters
[in]size_innumber of cells in the CellStatusArray

Definition at line 79 of file delaunay_sync.h.

◆ ~CellStatusArray()

GEO::CellStatusArray::~CellStatusArray ( )
inline

CellStatusArray destructor.

It is illegal to destroy a CellStatusArray if

  • threads are still running
  • there exists a cell with a status different from FREE_CELL

Definition at line 90 of file delaunay_sync.h.

Member Function Documentation

◆ acquire_cell()

cell_status_t GEO::CellStatusArray::acquire_cell ( index_t  cell,
cell_status_t  status 
)
inline

Tentatively acquires a cell.

Parameters
[in]cellthe index of the cell
[in]statusthe status to be written in the cell if acquisition is successful, that is, if the current status of the cell is FREE_CELL
Returns
FREE_CELL if acquisition was successful, or the id of the thread that owns cell otherwise.

Definition at line 113 of file delaunay_sync.h.

◆ cell_is_marked_as_conflict()

bool GEO::CellStatusArray::cell_is_marked_as_conflict ( index_t  cell) const
inline

Tests whether a cell is marked as conflict.

Parameters
[in]cellthe cell
Return values
trueif cell is marked as conflict
falseotherwise
See also
mark_cell_as_conflict()

Definition at line 158 of file delaunay_sync.h.

◆ cell_thread()

cell_status_t GEO::CellStatusArray::cell_thread ( index_t  cell) const
inline

Gets the thread that acquired a cell.

Parameters
[in]cellthe cell
Returns
the index of the thread that acquired the cell, or FREE_CELL if the cell is free

Definition at line 143 of file delaunay_sync.h.

◆ clear()

void GEO::CellStatusArray::clear ( )
inline

Clears this CellStatusArray.

Deallocates all memory

Precondition
all the cells are free and no concurrent thread is running

Definition at line 274 of file delaunay_sync.h.

◆ grow()

void GEO::CellStatusArray::grow ( )
inline

Increases the size of the array for one additional element.

capacity is doubled each time additional space is needed

Definition at line 253 of file delaunay_sync.h.

◆ mark_cell_as_conflict()

void GEO::CellStatusArray::mark_cell_as_conflict ( index_t  cell)
inline

Marks a cell as conflict.

Parameters
[in]cellthe cell
Precondition
the cell is owned by the current thread

Definition at line 173 of file delaunay_sync.h.

◆ release_cell()

void GEO::CellStatusArray::release_cell ( index_t  cell)
inline

Releases a cell.

Parameters
[in]cellthe index of the cell
Precondition
the cell is owned by the current thread

Definition at line 132 of file delaunay_sync.h.

◆ reserve()

void GEO::CellStatusArray::reserve ( index_t  new_capacity)
inline

Reserves additional space.

Parameters
[in]new_capacityon exit, this CellStatusArray will have at least sufficient space for new_capacity elements without needing to reallocate. Size is not modified. Operates like its std::vector counterpart.

Definition at line 243 of file delaunay_sync.h.

◆ resize() [1/2]

void GEO::CellStatusArray::resize ( index_t  size_in)
inline

Resizes this CellStatusArray.

Parameters
[in]size_innumber of cells
Precondition
all cells are free and no concurrent thread is currently running

Definition at line 232 of file delaunay_sync.h.

◆ resize() [2/2]

void GEO::CellStatusArray::resize ( index_t  size_in,
index_t  capacity_in 
)
inline

Resizes this CellStatusArray.

Parameters
[in]size_innumber of cells
[in]capacity_intotal number of allocated cells
Precondition
capacity_in >= size_in and no concurrent thread is currently running

Definition at line 204 of file delaunay_sync.h.

◆ set_cell_status()

void GEO::CellStatusArray::set_cell_status ( index_t  cell,
cell_status_t  status 
)
inline

Sets the status of a cell.

Parameters
[in]cellthe index of the cell

uses relaxed memory ordering

Precondition
the cell is owned by the current thread

Definition at line 192 of file delaunay_sync.h.

◆ size()

index_t GEO::CellStatusArray::size ( ) const
inline

Gets the size of this CellStatusArray.

Returns
the number of cells

Definition at line 265 of file delaunay_sync.h.


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