# The Support Kit: BAutolock

Derived from: none

Declared in: be/support/Autolock.h

Library: libbe.so

## Overview

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:

       BAutolock autolocker(myWindow);
       if ( autolocker.IsLocked() ) {
           . . .
       }

When the stack frame is destroyed, the BAutolock object unlocks the target object and then is itself destroyed.

## Constructor and Destructor

### BAutolock()

          inline BAutolock(BLooper *looper)
          inline BAutolock(BLocker *locker)
          inline BAutolock(BLocker &locker)

Locks the target looper or locker object.

### ~BAutolock()

          inline ~BAutolock()

Unlocks the target BLooper or BLocker.

## Member Functions

### IsLocked()

          inline bool IsLocked(void)

Returns `true` if the target BLooper or BLocker is locked, and `false` if not.

The Be Book, in lovely HTML, for BeOS Release 3.

Copyright © 1998 Be, Inc. All rights reserved.

Last modified March 26, 1998.