|
Boost : |
From: Branko Èibej (branko.cibej_at_[hidden])
Date: 2000-06-01 05:45:15
Well,
Since I've been working on this for some time now, I decided to
put it in the vault (folder synchronization). It's a first stab
at defining an interface for basic synchronization primitives and
synchronized operations. The basic premise is that implicitly locking
an object (i.e., locking within methods) is a Bad Thing, because s)
in general it doesn't prevent races, and b) can lead to deadlocks (because
locking order is not defined explicitly).
What's in:
- lock types (mutex, spinlock, rwlock)
- atomic counter (for decrement-and-test)
- sequencer and event count
- condition (paired with mutex)
- helper classes (lockable, watiable)
- constructs for synchronization (sentinel, synchronized())
I've included an (almost-complete) implementation using POSIX threads
(a Win32 implementation is in the works), and two test cases, all tested
with (very) recent versions of g++.
This interface is of course far from complete, but I suppose it's
a good starting point for an answer to the first challenge :-)
Please take a look and comment.
Regards,
Brane
-- Branko Èibej <branko.cibej_at_[hidden]> HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia voice: (+386 1) 586 53 49 fax: (+386 1) 586 52 70
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk