\( \newcommand{\E}{\mathrm{E}} \) \( \newcommand{\A}{\mathrm{A}} \) \( \newcommand{\R}{\mathrm{R}} \) \( \newcommand{\N}{\mathrm{N}} \) \( \newcommand{\Q}{\mathrm{Q}} \) \( \newcommand{\Z}{\mathrm{Z}} \) \( \def\ccSum #1#2#3{ \sum_{#1}^{#2}{#3} } \def\ccProd #1#2#3{ \sum_{#1}^{#2}{#3} }\)
CGAL 4.14.3 - STL Extensions for CGAL
SurjectiveLockDataStructure Concept Reference

Definition

The concept SurjectiveLockDataStructure describes functionalities of a data structure whose goal is to lock objects in a multi-threaded environment. Such data structures are intended to be used by concurrent algorithms.

Note that it is allowed to "lock too much". E.g., the data structure might be a voxel grid and locking a point might be locking the voxel containing this point. Thus, a point may also be locked because another point in the same voxel has been locked. The only requirement is that when a thread owns the lock of an object, no other thread can lock the same object.

We call S the surjective function such that S(object) is the "thing" that is locked when one tries to lock object. In the previous example, S(point) is the voxel containing point.

Has Models:
CGAL::Spatial_lock_grid_3

Operations

template<typename T >
bool is_locked (const T &object)
 Test if object is locked (by this thread or by any other thread).
 
template<typename T >
bool is_locked_by_this_thread (const T &object)
 Test if object is locked by this thread.
 
template<typename T >
bool try_lock (const T &object)
 Try to lock object. Returns true if the object is already locked by this thread or if the object could be locked.
 
template<bool no_spin, typename T >
bool try_lock (const T &object)
 Try to lock object. More...
 
void unlock_everything_locked_by_this_thread ()
 Unlock everything that is locked by this thread.
 
template<typename T >
void unlock_everything_locked_by_this_thread_but_one (const T &object)
 Unlock everything that is locked by this thread except S(object).
 

Member Function Documentation

◆ try_lock()

template<bool no_spin, typename T >
bool SurjectiveLockDataStructure::try_lock ( const T &  object)

Try to lock object.

Returns true if the object is already locked by this thread or if the object could be locked.

Template Parameters
no_spinIf true, force non-blocking operation (in any case, the function will return immediately, i.e. it will not wait for the ressource to be free). If false, use the default behavior (same as previous function).