Back to Jetson Inference

Jetson Inference: Mutex Class Reference

docs/html/classMutex.html

latest3.7 KB
Original Source

| | Jetson Inference

DNN Vision Library |

Public Member Functions | Protected Attributes | List of all members

Mutex Class Reference Utilities Library (jetson-utils) » Multithreading

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.

ReturnsTrue 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:

  • jetson-utils/Mutex.h

  • Mutex

  • Generated on Fri Mar 17 2023 14:29:30 for Jetson Inference by 1.8.17