Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-06-27 13:38:20


[Greg Colvin]
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.

[Gary]
I would prefer a second boost layer that does the reference counting. So
that when I don't need/want/can't/use it I don't have to.

  class Thread_ref {
  public:
      Thread_ref(Thread_id) {}
  };

where Thread_id is not copyable and a Thread_ref is.

I know it adds complexity but my recent experience with shared_ptr<> has
made me very wary of them. (The once you make a raw pointer shared, there is
no way to "unshare it or release it, as in pass the ownership to something
else.) While I admit this is less of an issue for threads, I would prefer
the extra helper layer. (Even if all the higher levels all use the
Thread_ref objects.)

I'd also supply a creation/conversion fn.

 Thread_ref threads::createRefThread(proc);

  Yours,
 -gary-

gary.powell_at_[hidden]


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