|
Boost : |
From: scleary_at_[hidden]
Date: 1999-12-28 08:32:53
Giora Unger wrote:
> 1. As far as I understand, the library is NOT thread safe.
> Am I wrong ?
> For example, let's examine line 169 in smart_ptr.h:
> if (--*pn == 0) { delete px; }
> I believe, that in case of two threads concurrently accessing
> this line (the reset() method), and an initial reference count==2,
> then a crash is possible: if both decrements occur before both
> comparisons, resulting in two deletion attempts.
The smart pointers are just as thread-safe as integers. To use them in a
thread-safe way, protect them just as you would any other non-thread-safe
fundamental type/class/library.
Should we look at doing a portable multi-threading library? I have the
beginnings of one, but it doesn't allow timed waits or waiting for multiple
objects -- would these be considered essential or optional?
-Steve
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk