|
Threads-Devel : |
From: Anthony Williams (anthony_at_[hidden])
Date: 2008-01-30 04:21:48
Quoting joop renes <jj.renes_at_[hidden]>:
> in a hobby project i need to work with pointers to a family of
> polymorphic objects and i want to do multi-threaded computations with
> them. does boost have thread-safe smart pointers? i tried Loki but run
> into problems to find the correct policy classes fot the multi-threaded
> case
> any suggestions please?
It depends what you're trying to do. You can safely pass shared_ptrs
around between threads, provided you don't update the same instance
from multiple threads at the same time, or update an instance from one
thread whilst reading it from another. It's quite OK to copy
shared_ptrs (even those that refer to the same object) in multiple
threads concurrently --- the reference count is thread safe.
Anthony
-- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL