#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 |
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.
|
inline |
Construct a lock that represents this object
|
inline |
Take the lock waiting the longest possible time for it to become available.
| bool SimpleSpinLock::tryLock | ( | ) |
tries the lock and returns immediately if it was already locked by us.
| bool SimpleSpinLock::spinLock | ( | unsigned long | iterations | ) |
Attempt to take the lock using a spin wait, it only returns true if the lock was taken.
| number | of iterations to wait, each iteration is at least 100 mics |
| void SimpleSpinLock::unlock | ( | ) |
Release the lock taken by spinlock or lock. DOES NOT check that the callee is correct so use carefully.