Jetson Inference
DNN Vision Library

A lightweight mutual exclusion lock. More...

#include <Mutex.h>

Public Member Functions

 Mutex ()
 Constructor. More...
 
 ~Mutex ()
 Destructor. More...
 
bool AttemptLock ()
 If the lock is free, aquire it. More...
 
void Lock ()
 Aquire the lock, whenever it becomes available. More...
 
void Unlock ()
 Release the lock. More...
 
void Sync ()
 Wait for the lock, then release it immediately. More...
 
pthread_mutex_t * GetID ()
 Get the mutex object. More...
 

Protected Attributes

pthread_mutex_t mID
 

Detailed Description

A lightweight mutual exclusion lock.

It is very fast to check if the mutex is available, lock it, and release it. However, if the mutex is unavailable when you attempt to lock it, execution of the thread will stop until it becomes available.

Constructor & Destructor Documentation

◆ Mutex()

Mutex::Mutex ( )
inline

Constructor.

◆ ~Mutex()

Mutex::~Mutex ( )
inline

Destructor.

Member Function Documentation

◆ AttemptLock()

bool Mutex::AttemptLock ( )
inline

If the lock is free, aquire it.

Otherwise, return without waiting for it to become available.

Returns
True if the lock was aquired, false if not.

◆ GetID()

pthread_mutex_t* Mutex::GetID ( )
inline

Get the mutex object.

◆ Lock()

void Mutex::Lock ( )
inline

Aquire the lock, whenever it becomes available.

This could mean just a few instructions if the lock is already free, or to block the thread if it isn't.

◆ Sync()

void Mutex::Sync ( )
inline

Wait for the lock, then release it immediately.

Use this in situations where you are waiting for an event to occur.

◆ Unlock()

void Mutex::Unlock ( )
inline

Release the lock.

Member Data Documentation

◆ mID

pthread_mutex_t Mutex::mID
protected

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