The BAutolock
class provides an easy mechanism for automatically locking
and unlocking a
BLocker
object or, more typically, a
BLooper.
All you need to do is allocate a
BAutolock
object on the stack and pass it a target
BLocker
or BLooper.
You may want to make sure the lock is in place before proceeding:
BAutolockautolocker(myWindow); if (autolocker.IsLocked() ) { . . . }
When the stack frame is destroyed, the
BAutolock
object unlocks the target object and then is itself destroyed.