« Return to Thread: [thread] Expected behaviour of condition variable wait when the mutex is not locked

Re: [thread] Expected behaviour of condition variable wait when the mutex is not locked

by Johan Torp :: Rate this Message:

Reply to Author | View in Thread

I'm not sure what's best in this case. I find that there is often a certain trade-off between ease of use and runtime insecurities.

For instance, it would have been useful to have a strict shared_ptr which could never be null. It's implemented easily by removing the default constructor and reset() and check+throw for non-null ptrs in the regular constructor and reset(T*). You would lose default-constructibility so you probably want to make the decision optional. Even if this could be implemented nicely by some policy parameter+default parameter, the option would mean a larger and more complicated abstraction for the user.

Best Regards, Johan


 « Return to Thread: [thread] Expected behaviour of condition variable wait when the mutex is not locked