Reputation: 329
i was working on the reversed worker/consumer pattern. Between these 4 methods i will do write/read operations.
...
void beginWrite();
void endWrite();
void beginRead();
void endRead();
...
I only know for scoped shared/unique lock. So how is this done manually via shared/unique lock? So i would lock shared in beginRead and release in endRead. Or lock/release in another thread unique lock?
Upvotes: 0
Views: 117
Reputation: 182761
Boost's shared locks have functions that perfectly corresponding to the functions you listed. They are lock
(get exclusive lock), unlock
(release exclusive lock), lock_shared
(get shared lock), and unlock_shared
(release shared lock).
Upvotes: 1