Re: Fwd: memory
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtkmm-list gnome org
- Cc:
- Subject: Re: Fwd: memory
- Date: Wed, 17 May 2006 21:17:25 +0100
On Tuesday 16 May 2006 11:16, Ramashish Baranwal wrote:
> boost::shared_ptr is thread safe.
"Thread safe" can mean many different things. boost::shared_ptr<> is thread
safe in the sense in which a bare pointer is thread safe.
It means that you can safely reference an object with shared pointers in one
thread and the same object with different instances of shared pointer in
another thread. But you cannot safely modify a shared pointer (ie apply a
non-const operation to the shared pointer) in one thread and read from or
modify the same instance of shared pointer in another thread. (And of course
you cannot safely modify the referenced object in one thread and read or
modify it in another thread, unless the object does its own locking.)
What this means is that you can have the same object referenced by a container
of shared pointers in one thread and a container of shared pointers in
another thread provided that you arrange separate locking of the referenced
object. The circumstances in which you might want to do that are quite
limited.
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]