Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-06-27 08:44:39


--- In boost_at_y..., <llee1_at_l...> wrote:
> On Tue, 26 Jun 2001, Jeremy Siek wrote:
>
> >
> > Here's an alternative interface, mostly due to Rich Lee.
>
> In fact, I have changed the interface from free functions to class
as
> follows:
>
> template <class Obj,
> class Feature1=default_template_arg,
> class Feature2=default_template_arg,
> class Feature3=default_template_arg >
> class thread {
> public:
> thread(Obj* o_);
> void run();
>
> void join();
> void detach();
>
> void yield();
>
> ~thread();
> };
>
> Where Feature1, Feature2, and Feature3 are for ContentionScope,
> DetachState, and SchedulePolicy.

These "features" are currently left out on purpose. They are not
necessary for most purposes, and they don't exist on all platforms.
I'm shooting for a minimal yet complete interface to begin with.
Advanced concepts can be added as demand and analysis on portability
can be done properly.

You also opted for the two phased construction that I don't think is
a good idea. It doesn't add any benefit (at least that's been
pointed out to me yet), while it complicates usage.

This design also doesn't provide a self() method, which I think may
be necessary.

Also, yield should be a static method, especially if self() does not
exist.

There's also a few bugs in the implementation. The detached state is
not synchronized, making this class not thread safe. Join sets the
state to not-detached, when in fact there should be a third state,
lest some operations result in errors.

After all of this, this is in essence the third design I suggested.

Bill Kempf


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