up: THREAD     index Zimbu documentation

CLASS T.autoLock @public

summary

     

The builtin type autoLock: an object that keeps a lock and releases it when destructed.

Put the object on the stack to make sure the destructor is called when leaving the block. Otherwise it only happens when the garbage collector finds the object unused, which may be much later.

Typical use:

  {
    autoLock %al = NEW(myLock)
    # Do something that might crash
  } # %al.Finish() calls myLock.end() here, always

NEW(lock) @public  Calls lock.begin().
$Finish() status @public  Destructor: calls end() on the lock the object was created with.
 

members (alphabetically)

     

PROC NEW(THREAD.Lock lock) @public

     

Calls lock.begin().

FUNC $Finish() status @public

     

Destructor: calls end() on the lock the object was created with.

Can be called multiple times, end() will only be called once.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0