I have read-only copies of juce::String passed (safely with a lock) between two threads. Is the release guaranteed thread-safe (ala std::shared_ptr)? I can not find an explicit answer into the forum/documentation.
The reference counter is a std::atomic<int> (see the StringHolder struct in juce_String.cpp), so I would assume that this makes it thread safe in the same way that std::shared_ptr or juce::ReferenceCountedObject is thread safe. Incrementing and decrementing should be safe across threads, but copying and assigning should be locked, as you mentioned.
1 Like
Thanks, but without any guarantee that it remains true in the future (even if it is almost sure it will), that’s hazardous IMHO to rely on it. I have a workaround ; but it relies on moved juce::String destructor to be thread-safe ; i’m sure it is ; but not guaranteed neither. ![]()
