On 03/14/2011 01:59 PM, Carl Trieloff wrote:
On 03/11/2011 06:14 AM, Gordon Sim wrote:
..the iterator may be invalidated by a subsequent update to the map
once the lock is released. Testing against bindingCache.end() outside
the lock is also not safe.
I don't believe so, as it holds a smart pointer, the smart pointer will
hold the memory from .second, so
even if the map is released the memory will remain safe. This is the
whole point of the code, that you
can free the map under the current route. the smart pointer protects the
memory.
Its the iterator that is the issue, not the smart pointer that it points
to. You test (it == bindingCache.end()) outside the lock and that is not
safe.
So the commit is thread safe.
I can assign second to a local smart pointer under the lock to make it
more readable, but the code is
thread safe.
Carl.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org