Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-20 06:54:17


[1] No atomic_t, why? A noncopyable thread needs shared_ptr, and shared_ptr
needs atomic_t for thread safe reference count updates; it seems that
atomic_t is at the same level as boost::thread. Of course I can hack my own
shared_ptr using Interlocked*, but this rather defeats the purpose.

[2] I have the following problem. I'm trying to create a non-local thread
object:

shared_ptr<thread> p(new thread(f));

_but_ I also want to pass 'p' to the newly created thread. I don't see a
simple way to achieve this. In a two-phased construction design this is
trivial:

shared_ptr<thread> p(new thread); // creates a 'detached' thread object
p->create(bind(f, p)); // create the thread and associate it with *p

Of course two phased construction is evil.

The problem doesn't arise when I code directly to win32 or pthreads, which
means that it's (possibly) a defect in the design (minimal but not
complete.)

Opinions?

--
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