#include <virtual_basic_lockable.h>
Public Member Functions | |
void | lock () |
void | unlock () |
Protected Types | |
enum class | Operation { kLock , kUnlock } |
Private Member Functions | |
virtual void | DoLockOperation (Operation operation)=0 |
The VirtualBasicLockable
is a virtual lock abstraction for locks which meet the C++ named BasicLockable requirements of lock() and unlock().
This virtual indirection is useful in case you need configurable lock selection in a portable module where the final type is not defined upstream and ergo module configuration cannot be used or in case the lock type is not fixed at compile time, for example to support run time and crash time use of an object without incurring the code size hit for templating the object.
|
privatepure virtual |
Uses a single virtual method with an enum to minimize the vtable cost per implementation of VirtualBasicLockable
.
Implemented in pw::sync::GenericBasicLockable< LockType >, pw::sync::GenericBasicLockable< InterruptSpinLock >, pw::sync::GenericBasicLockable< Mutex >, pw::sync::GenericBasicLockable< TimedMutex >, and pw::sync::NoOpLock.