|
Boost Users : |
From: Andrew Holden (aholden_at_[hidden])
Date: 2007-12-18 13:12:22
Zeljko Vrba [zvrba_at_[hidden]] wrote:
> He might just allocate the shared_ptr on the heap (the
> dynamic memory allocation will be anyway cheaper than thread
> creation):
>
> void *thread(void *ptr)
> {
> shared_ptr<X> *_p = static_cast<shared_ptr<X>*>(ptr);
> shared_ptr<X> p = *_p;
> delete _p;
> ...
> }
>
> void creator()
> {
> ...
> pthread_create(&thrid, 0, thread, new shared_ptr<X>(orig_ptr));
> ...
> }
>
> No need for any additional synchronization.
Good point. And certainly much simpler than my solution.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net