#include <x/lockpool.H> typedef x::sharedlockpool<> sharedpool_t; sharedpool_t sharedpool(sharedpool_t::create()); sharedpool_t::lockentry rlock(sharedpool->addLockSet(sharedpool_t::create_shared, x::eventfd::create()); sharedpool_t::lockentry rlock(sharedpool->addLockSet(sharedpool_t::create_unique, x::eventfd::create());
x::sharedpool
is a specialization of a lock pool
that implements the semantics of
std::shared_mutex
.
The single template parameter specifies the
lock starvation option.
In this specialization, the default
starve
value is false
.
create_shared
() creates a shared lock.
create_unique
() creates a unique lock.
Once a unique lock is in the lock pool's waiting list, any subsequent
shared locks queue up on the waiting list until all existing shared locks
go out of scope, permitting the waiting unique lock to acquire the lock
pool. This ensures that the unique lock gets eventually acquired.
Setting starve
to true
results
in shared locks starving any pending unique locks as long as at least
one shared lock exists, until all shared locks
go out of scope.
Prev | Up | Next |
Chapter 23. A pool of locks that use event file descriptors | Table Of Contents | Mutually-exclusive lock pools |