
2 Apr
2008
2 Apr
'08
8:50 p.m.
Frank Mori Hess schrieb:
Incidentally, I find the example usage of lock acquirers in the thread_lockable examples a bit verbose and dangerous. That is stuff like:
mbox::writelock_acquirer<mutexlockable_int> int_lock(*pLockableInt); int& i = access_acquiree(int_lock); i = 5;
Why not just support operator* (and operator-> for calling class methods) on the lock_acquirer class? Then you could do something like:
I like the less verbose method with operator*... the intent is to force a named lvalue lock_acquirer object.
mbox::writelock_acquirer<mutexlockable_int> int_lock(*pLockableInt); *int_lock = 5;
But what prevents me from writing: int& i = *int_lock; Klaus