Examples of Lock

Example:

       LOCK A,^B,@C
       LOCK (A,B,@C)
        

The first LOCK command LOCKs A and unLOCKs A before LOCKing ^B, then unLOCKs ^B before locking the name specified by the variable C. The second LOCK command acquires all three resources at once. GT.M waits until all the named resources in the argument list become available before LOCKing all the resources. For example, if the resource specified by the variable C is not available for LOCKing, GT.M waits until that resource becomes available before LOCKing A and ^B.

Example:

       LOCK (A,B)
       LOCK +C
       LOCK -B
        

This LOCKs A and B, then incrementally LOCKs C. Finally it releases the LOCK on B, while retaining the LOCKs on A and C.

Example:

       LOCK (A,B,C) 
       LOCK +(B,C)
       LOCK -(B)
        

This LOCKs A, B and C together. It then increments the lock "counts" of B and C. The last LOCK command removes one "count" of B, leaving one count of A and B and two counts of C.

Example:

          LOCK ^D:5
        

This command attempts to LOCK ^D with a timeout of five seconds. If LOCK acquires the named resource before the timeout elapses, GT.M sets $TEST to 1 (TRUE). If LOCK fails to acquire the named resource before the timeout elapses, GT.M sets $TEST to 0 (FALSE).