Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-04 06:47:32


From: "Gary Powell" <Gary.Powell_at_[hidden]>
> I'm thinking back to my previous job with embedded systems. I would like
to
> see boost::thread become std::thread. Thus if its in the interest of the
> extremely limited OS to not ref count the threads, the language shouldn't
> mandate it.

It's not hard for the OS to ref-count the threads, even for an embedded OS.
thread::ref will contain a simple pointer into a static array of thread
objects, eliminating dynamic allocation. thread::ref will use intrusive
counting.

> Hence I'm still suggesting two layers. With the Caveat that Bill make the
> first one as the non copyable thread class.

Exposing the first layer seems, on first sight, to provide the best of both
worlds, but this has drawbacks as well. Hiding the implementation is usually
a good thing, since it prevents recompilation when the implementation
changes.

Consider:

void f()
{
    thread t; // needs 'thread' to be completely defined
}

versus

class thread::ref
{
    class impl;
    impl * p;

public:

// interface
};

void f()
{
    thread::ref r; // doesn't need thread::ref::impl (the equivalent of
'thread') to be defined
}

--
Peter Dimov
Multi Media Ltd.

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