Go to the first, previous, next, last section, table of contents.


Class Lock

Class Lock implements what are traditionally termed "semaphores", used to keep multiple jobs from stepping on each other when they update the db. The canonical usage pattern is

( new object )  --> obj
makeLock       --> obj.lock

when creating an object, and then

obj.lock with-lock-do{
    ( Update object )
}

The server does not explicitly associate a lock with any particular object or property: It is up to you to decide what values the lock protects, and to ensure that all code accessing those values respects the lock.

The with-lock-do{...} syntax blocks the job until it can obtail sole control of the lock, then executes the given code with that control, meaning that any other jobs attempting to obtain the lock will block until we exit the construct.

Class Lock adds the following properties to those of Class Plain:

$S.heldBy:  NIL or else the job holding the lock.

Note: For convenience, the $S properties are also available in the public (default) propdir.


Go to the first, previous, next, last section, table of contents.