Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-06-27 13:25:56


From: Beman Dawes <bdawes_at_[hidden]>
> At 01:08 PM 6/27/2001, Greg Colvin wrote:
> >For the reasons Peter and I have laid out I still prefer:
> >
> > namespace thread {
> >
> > struct ref {
> >
> > // ref is copyable, and all copies compare ==
> > ref(const ref& other);
> > ref& operator=(const ref& other);
> > bool operator==(const ref& other) const;
> > bool operator!=(const ref& other) const;
> >
> > // To allow us to not need current(), at least for
> > // comparison. Not needed if we have current().
> > bool is_current() const;
> >
> > bool is_alive() const;
> >
> > // Waits for the thread to finish
> > void join();
> > };
> >
> > // maybe don't need this if we have ref::is_current()
> > ref current() const;
> >
> > ref create(detail::threadproc proc); // Starts the thread
> >
> > void sleep(const xtime& xt);
> > void yield();
> > };
>
> What about detach()?

Unecessary, I think, as there is no thread object to detach
from, and redundant with ~thread::ref().

> What about ~ref()?
>
> Was the omission of these deliberate? (Just curious:-)

No, I just assumed it would do the right thing.

Also, some of us seem to dislike member functions enough that
we should have

    thread:is_alive(const thread::ref&);
    thread:join(const thread::ref&);

instead of the members. I have no strong opinion on this
myself. I also don't care much if ref is called id or
whatever, but somehow I think ref goes better with the
member functions, and id with the free functions.

What is important to me is having a safely copyable handle
for managing a thread, as I think that trying to roll my
own with shared_ptr will be perilous and more difficult
and less efficient than necessary.


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