std::string & multithreading
Marc Glisse
marc.glisse@normalesup.org
Fri Feb 26 11:32:00 GMT 2010
On Fri, 26 Feb 2010, Radu Marginean wrote:
> Currently std::string cannot be safely used in a multithreaded
> environment due to features like copy on write and reference counting.
> Even programs that access two unrelated different string objects in a
> multicore machine may suffer random crashes.
Is that really the case? Last time I checked, the implementation didn't
use any global/static variables, so no reason for unrelated strings to
interact, and the reference counting used atomic operations, which is
enough to allow for quite a few multithreading scenarios. Now obviously
that doesn't make operations on strings atomic, but that is seldom needed.
For what precise use did you notice these random crashes?
--
Marc Glisse
More information about the Libstdc++
mailing list