Boost logo

Boost :

From: brent verner (brent_at_[hidden])
Date: 2000-08-18 16:05:55


On 18 Aug 2000 at 19:28 (-0000), William Kempf wrote:
| --- In boost_at_[hidden], "Greg Colvin" <gcolvin_at_u...> wrote:
| > Earlier I suggested that the lock, wait condition, and notify could
| be
| > combined into a single object with a templated constructor.
|
| This doesn't address the problem. Just combining them into a single
| object won't solve the problem of needing the mutex to be locked
| during calls to wait() and notify().
|
| Besides, the lock can't be combined in this way, and combining the
| mutex and condition forces us to a one-to-one relationship. Since it

I have always (right or wrong) seen a one-to-one relationship with
condition->mutex, but that mutex could usefully be locked outside
of the condition... i.e. to suspend the conditions wait() state
from a controlling thread, since the condition must lock then unlock
its mutex to enter the waiting state.

(I ramble... trying to see your point... excuse me... play along...)
if a number of (different) conditions share a mutex, a thread waiting
on its condition will be run -- acquiring the mutex. the mutex becomes
a serialization point for the (different) conditions that use it...
ah, I see... yes this would be useful. thank you for stretching my
mind :)

| can be very beneficial to use multiple conditions with a single mutex
| I don't want to combine these two concepts. Not to mention not
| wanting to force the overhead of a condition on everyone that uses a
| mutex.

I agree with you. CV has a mutex. It would not be that difficult to
have two ctors for a CV, would it?

  basic_mutex* __m;
  bool __del_m;
  basic_condition() : __m( new basic_mutex() ) : __del_m(true) { }
  basic_condition( basic_mutex* m ) : __m( m ) : __del_m(false) { }

  brent

-- 
Damon Brent Verner                        o      _     _         _
Cracker Jack® Surprise Certified  _o     /\_   _ \\o  (_)\__/o  (_)
brent_at_[hidden]                _< \_   _>(_) (_)/<_    \_| \   _|/' \/
brent_at_[hidden]               (_)>(_) (_)        (_)   (_)    (_)'  _\o_

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk