|
Boost : |
From: áÎÄÒÅÊ óÅÍÁÛÅ× (andysem_at_[hidden])
Date: 2007-09-20 14:01:10
-----Original Message-----
From: Anthony Williams <anthony_w.geo_at_[hidden]>
To: boost_at_[hidden]
Date: Thu, 20 Sep 2007 16:46:11 +0100
Subject: Re: [boost] lightweight_once
>
> Andrey Semashev <andysem_at_[hidden]> writes:
>
> > Hello Anthony,
> >
> > Tuesday, August 28, 2007, 12:17:45 PM, you wrote:
> >
> > Would you be interested to take a look at my implementation? Maybe
> > after some cleaning up it could be moved to your official library?
>
> Sorry for the delay in replying.
>
> I've looked at the implementation in FSM.zip from the vault --- is that the
> one you meant? --- and with a quick glance it looks like you've opted for a
> check/sleep/check/sleep loop for threads that are waiting for another thread
> to finish running the routine. This is a bad idea. Blocking of this nature
> should be done by waiting on an OS primitive rather than with a wait loop.
Why is it that bad? This is safier since there is no opportunity to get an error on the threading primitive construction, it doesn't use system resources like kernel objects and it solves the fundamental problems of creating and destroying those threading primitives in run time. And it will be run only once after all, so performance is not an issue.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk