TaskManagerIO
Loading...
Searching...
No Matches
SimpleSpinLock Class Reference

#include <SimpleSpinLock.h>

Public Member Functions

 SimpleSpinLock ()
void lock ()
bool tryLock ()
bool spinLock (unsigned long iterations)
void unlock ()
uint8_t getLockCount () const
bool isLocked () const

Detailed Description

A very simple lock that can be used to provide a very simple mutex like behaviour based on task manager atomic constructs. It has the ability to try and spin lock, and also to fully lock in conjunction with TaskMgrLock class. Use only for activities that do not take very long, it cannot relinquish control to task manager, it freezes the bus when locked. You must never call yieldForMicros while locked.

Constructor & Destructor Documentation

◆ SimpleSpinLock()

SimpleSpinLock::SimpleSpinLock ( )
inline

Construct a lock that represents this object

Member Function Documentation

◆ lock()

void SimpleSpinLock::lock ( )
inline

Take the lock waiting the longest possible time for it to become available.

◆ tryLock()

bool SimpleSpinLock::tryLock ( )

tries the lock and returns immediately if it was already locked by us.

Returns
true if the lock was already owned by us, otherwise false

◆ spinLock()

bool SimpleSpinLock::spinLock ( unsigned long iterations)

Attempt to take the lock using a spin wait, it only returns true if the lock was taken.

Parameters
numberof iterations to wait, each iteration is at least 100 mics
Returns
true if the lock was taken, otherwise false

◆ unlock()

void SimpleSpinLock::unlock ( )

Release the lock taken by spinlock or lock. DOES NOT check that the callee is correct so use carefully.


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