Re: [sigc] Re: [gtkmm] libsigcx and gtkmm 2.4



Daniel Elstner wrote:

Sure, but the caller passes in an already constructed std::string.  As I
said above, you need to lock before constructing the object.


Hmmm. Let's see what's going on here...

1. An string object is created.
2. The shared mutex is locked.
3. A shared copy of the string object is made.
4. The mutex is unlocked.
5. The original string object is destroyed.

Now, the problem I see here is that the original string is destroyed after the mutex is unlocked. So if string isn't thread-safe this is a problem.

But if fail to see how locking the mutex before creating the original string would make any difference. Successfully locking or unlocking a mutex is guaranteed to synchronize memory with respect to other threads regardless of whether that memory was touched before or after the mutex was locked.

--
Christer Palm



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]