
Michael Glassford wrote:
Doug Gregor wrote:
On Tuesday 29 June 2004 9:15 am, Michael Glassford wrote:
For that purpose we'll need something like
scoped_lock(mutex&, nolock_t);
I'm increasingly liking this syntax, by the way; thanks for suggesting it.
I don't know the original intention, but my assumption about the "bool" parameter was that it was intended to be used to check (run-time) conditions that might eliminate the need for locking under certain circumstances, e.g.,
bool foo(bool threadsafe) { mutex::scoped_lock l(m, !threadsafe); }
Using types such as nolock_t would prevent such a usage.
I hadn't considered that, but I guess I'll have to now.
Would it be sufficient that the above use case would be supported like this: bool foo(bool threadsafe) { mutex::scoped_lock l(m, unlocked); if (!threadsafe) l.lock(); } ? Mike