CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | List of all members
CYB::API::Mutex Class Referenceabstract

A fast locking, no order guaranteed, mutex. More...

#include <Mutex.hpp>

Inheritance diagram for CYB::API::Mutex:
Inheritance graph
[legend]
Collaboration diagram for CYB::API::Mutex:
Collaboration graph
[legend]

Public Types

using Constructor = Interop::EmptyConstructor
 See Interop Construction. More...
 
- Public Types inherited from CYB::API::Interop::Allocatable
enum  ID {
  ID::NULL_ID, ID::File, ID::Mutex, ID::Path,
  ID::Semaphore
}
 Defines the IDs of allocatable engine objects. More...
 
using Constructor = NullConstructor
 Override in descendants.
 
using CopyConstructor = NullConstructor
 Override in descendants.
 

Public Member Functions

virtual ~Mutex ()=default
 Destroy a Mutex. Mutex must be unlocked.
 
virtual void Lock (void) noexcept=0
 Acquire a lock on a Mutex. This will block the current thread until the lock is aquired. The Mutex must not be owned by the current thread. More...
 
virtual bool TryLock (void) noexcept=0
 Attempt to acquire a lock on a Mutex. This will not block the current thread. The Mutex must not be owned by the current thread. More...
 
virtual void Unlock (void) noexcept=0
 Release a lock on a Mutex. Should only be called after a Lock or TryLock on the same Mutex was aquired in the same thread. More...
 
- Public Member Functions inherited from CYB::API::Interop::Allocatable
virtual ~Allocatable ()=default
 See Default Constructors and Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from CYB::API::Interop::Allocatable
template<class AParent >
static constexpr ID GetID (void)
 Returns the ID of an allocatable object. More...
 

Detailed Description

A fast locking, no order guaranteed, mutex.

WARNING
Using Mutex's incorrectly results in hard to detect undefined behaviour, proceed with caution

Definition at line 10 of file Mutex.hpp.

Member Typedef Documentation

See Interop Construction.

Exceptions
CYB::Exception::SystemDataError code: CYB::Exception::SystemData::MUTEX_INITIALIZATION_FAILURE Thrown if the mutex could not be initialized

Definition at line 16 of file Mutex.hpp.

Member Function Documentation

virtual void CYB::API::Mutex::Lock ( void  )
pure virtualnoexcept

Acquire a lock on a Mutex. This will block the current thread until the lock is aquired. The Mutex must not be owned by the current thread.

Thread Safety
This function requires no thread safety

Implemented in CYB::Platform::System::Mutex.

virtual bool CYB::API::Mutex::TryLock ( void  )
pure virtualnoexcept

Attempt to acquire a lock on a Mutex. This will not block the current thread. The Mutex must not be owned by the current thread.

Returns
true if the mutex was acquired, false otherwise
Thread Safety
This function requires no thread safety

Implemented in CYB::Platform::System::Mutex.

virtual void CYB::API::Mutex::Unlock ( void  )
pure virtualnoexcept

Release a lock on a Mutex. Should only be called after a Lock or TryLock on the same Mutex was aquired in the same thread.

Thread Safety
This function requires no thread safety

Implemented in CYB::Platform::System::Mutex.


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