
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 02 April 2008 16:50 pm, klaus triendl wrote:
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;
Nothing, it just makes it less tempting to do so. You only need to add one character (the asterisk) to get a reference from the lock_acquirer directly. Presumably, the only reason you were creating the reference before was because it was more convenient to write i = 5; than access_acquiree(int_lock) = 5; - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH9OGU5vihyNWuA4URAp8DAJ0fNWckUD0ADjUfmvuS1qe8KAaJgACgkplz mHOSapSE19SN4rY0YsFGPeQ= =EYOn -----END PGP SIGNATURE-----