Aren't there any plan to make the network package thread-safe ?
If I want to protect my objects manually, I've to write something like this :
xxx.Lock();
sharedObject.DoSomething();
xxx.Unlock();
or
{
sf::Lock l(xxx);
sharedObject.DoSomething();
}
And the things get even worth when a shared object is used in conditions : I've to get the result of the function between lock/unlock before using the condition, then do the condition test. Same when a shared object is used in a return statement.
Whereas if it was done on SFML's side.. of course it would be quite easier for me, but it wouldn't be too tricky for you. Besides it's not like protecting a function used hundreds of times per second. I don't think the protection overhead would be noticeable in this case.
I could obviously patch SFML myself but it would be a pain to maintain.
Edit: note that I can't protect the members for the whole function lifetime either because some are already blocking the thread by waiting on a selector, and in the meantime, another thread could request the use of one of the protected object to send a message to this selector => inter-blocking.
I wonder whether this isn't related to a bad conception though. What I've done is launching a TCP server in a thread which waits for messages from clients. When I wish to stop listening, the only way I found was to send a "kill" message to the server (I don't think killing the thread is fine for closing connections and all this kind of stuff). But.. in the meantime I'm writing this, I've been thinking of another solution : instead of waiting indefinitely for the selector to return, I could set a timeout of.. let's say one second, which would let me check if a boolean "shouldStopServer" has been set to true in the meantime. Thus I wouldn't have to use the socket, no more sharing... and no more inter-locking.
This issue with the ease of use of the network package remains though.