Honeycomb
0.1
Component-Model Framework
|
Enumerations | |
enum | Op { Op::lock, Op::tryLock, Op::adopt, Op::defer } |
Functions | |
template<class Lock , class... Locks, typename mt::disable_if< mt::isRange< Lock >::value, int >::type = 0> | |
int | tryLock (Lock &l, Locks &...ls) |
Try to lock all lockables. Locks either all or none. More... | |
template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0> | |
auto | tryLock (Range &&range) -> mt_iterOf(range) |
Try to lock all lockables in a range. Locks either all or none. More... | |
template<class... Locks, typename mt::disable_if< mt::isRange< mt::typeAt< 0, Locks... >>::value, int >::type = 0> | |
void | lock (Locks &&...locks) |
Lock all lockables safely without deadlocking. More... | |
template<class Range , typename std::enable_if< mt::isRange< Range >::value, int >::type = 0> | |
void | lock (Range &&range) |
Lock all lockables in a range safely without deadlocking. More... | |
ScopeGuard functors | |
template<class Lock > | |
function< void()> | lockGuard (Lock &lock) |
template<class Lock > | |
function< void()> | unlockGuard (Lock &lock) |
template<class Lock > | |
function< void()> | releaseGuard (Lock &lock) |
Mutex lock util.
|
strong |
void honey::lock::lock | ( | Locks &&... | locks | ) |
Lock all lockables safely without deadlocking.
Deadlock can be avoided by waiting only for the first lock, then trying to lock the others without waiting. If any of the others fail, restart and wait for a failed lock instead. For example:
Lock L1 and then call: tryLock(L2,L3,L4,L5) If L2 failed then restart, lock L2 and call: tryLock(L3,L4,L5,L1)
void honey::lock::lock | ( | Range && | range | ) |
Lock all lockables in a range safely without deadlocking.
function<void ()> honey::lock::lockGuard | ( | Lock & | lock | ) |
function<void ()> honey::lock::releaseGuard | ( | Lock & | lock | ) |
int honey::lock::tryLock | ( | Lock & | l, |
Locks &... | ls | ||
) |
Try to lock all lockables. Locks either all or none.
Returns the zero-based index of the first failed lock, or -1 if all locks were successful.
auto honey::lock::tryLock | ( | Range && | range | ) | -> mt_iterOf(range) |
Try to lock all lockables in a range. Locks either all or none.
Returns an iterator to the first failed lock, or end if all locks were successful.
function<void ()> honey::lock::unlockGuard | ( | Lock & | lock | ) |