Boost logo

Boost :

From: Hurd, Matthew (hurdm_at_[hidden])
Date: 2004-01-26 16:50:12

> On Behalf Of Sean Kelly
> Sent: Tuesday, 27 January 2004 8:08 AM
> To: Boost mailing list
> Subject: Re: [boost] Boost.Thread request: event object
> On Mon, 26 Jan 2004, Daryle Walker wrote:
> >
> > On 1/25/04 5:28 PM, "Matthew Hurd" <matt_at_[hidden]> wrote:
> >
> > [SNIP]
> > > But it does look neat.
> > >
> > > if (lock lk(guard_,t))
> > >
> > > and would release automagically as the if scope rolls out. I'm
> warming to
> > > it.
> > >
> > > if (lock lk(guard_,false), lk.acquire_timed(t) )
> > >
> > > would do the trick if it was valid c++, but I'm pretty sure it
> >
> > You're right, you CANNOT do:
> >
> > if ( Type Object1( XXX ) ) // possibly with ", Object2( YYY )",
> >
> > You can only do
> >
> > if ( Type Object = Whatever )
> >
> > or the "scoping in advance" trick you already showed.
> It looks like we're moving towards a shared_ptr type design for this
> object. But the simple cases still work:
> if( lock l = guard )
> or:
> if( lock l = lock(guard,t))
> or better yet:
> if( lock const& l = lock(guard,t))

I like this last one, though I suspect I'll end up with

        if (lock lk(guard,t))

in my code as it will be the first thing I'll think of.

Not sure I understand where we are with events:

Can we wrap the acceptance of events from the OS, win32 in particular,
into a scoped acquisition without introducing race or performance

I'm not suggesting an event mechanism just being able to use the OS

Syntax for mutexes:

        mutex guard;

        if (lock lk(guard,t)) {


Syntax for other resource offering:

        socket_event e;
        if (lock lk(e,t)) {


Lock seems a bad name. Any good short names for an "acquirer" that
would make sense for a socket, file i/o, timer, mutex?

Under the covers on win32 the "acquirer" for the resource just uses

Does this work for you?


Matt Hurd.

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

Boost list run by bdawes at, gregod at, cpdaniel at, john at