Synchronization Objects

The synchronization objects are defined in the tool_mutex.h file.

Locks

By default the kernel uses lock classes implemented on the basis of system synchronization API that enables safe use of alternative parallel frameworks (not only OpenMP) in user applications.

But the kernel can be switched to using locks based on OpenMP locks.

On Windows system locks by default are implemented on the basis of critical sections. On Linux system locks are implemented on the basis of pthread_mutex_t.

The lock classes implementation is controlled by the C3D_NATIVE_LOCK variable. Redefining the C3D_NATIVE_LOCK variable in user applications is prohibited.

The CommonMutex and CommonRecursiveMutex classes define lock and recursive lock. They provide the lock() and unlock() methods.

The ScopedLock and ScopedRecursiveLock classes define scoped lock and scoped recursive lock. They can accept a null pointer to a mutex. Locking occurs if the pointer to the mutex is nonzero and the code runs in parallel.

Base Synchronization Objects

The MbSyncItem class is the base synchronization object with lazy initialization. It creates a lock (mutex) when needed and implements the Lock() and Unlock() methods.

The MbNestSyncItem class is the base synchronization object with lazy initialization which supports nested locks. It creates a lock (mutex) when needed and implements the Lock() and Unlock() methods.

The MbPersistentSyncItem class is the base synchronization object implementing the Lock() and Unlock() methods. It always creates a lock (mutex).

The MbPersistentNestSyncItem class is the base synchronization object which supports nested locks. It implements the Lock() and Unlock() methods and always creates a lock (mutex).

The kernel objects that need synchronization are inherited from one of these classes.