Locking Objects

In the Jade language, you can use the exclusiveLock, sharedLock, reserveLock, and updateLock methods of the Object class to manually lock objects. (The Jade Application Programming Interface also provides calls for locking objects manually from external languages.) The valid concurrent lock combinations are shown in the following table.

  Share Reserve Update Exclusive
Share Yes Yes Yes No
Reserve Yes No No No
Update Yes No No No
Exclusive No No No No

More than one shared lock can coexist for the object at any time but only one exclusive lock is allowed. Additionally, a reserve lock can coexist with any number of shared locks but is incompatible with another reserve lock or with an exclusive lock. If the object to be locked is already locked in an incompatible manner by another user or sub-user, an exception is raised.

The lock types and their global constant definitions (if applicable) are listed in the following table.

Locks Global Constant Integer Description
Get_Lock 0 Waiting to acquire a lock and forcing all other lock requests to be queued
Share_Lock 1 Shared lock
Reserve_Lock 2 Reserve lock
Exclusive_Lock 3 Exclusive lock
Update_Lock 4 Update lock

The lock duration global constant definitions are listed in the following table.

LockDurations Global Constant Integer
Transaction_Duration 0
Session_Duration 1
Persistent_Duration (reserved for future use) 2

The lock timeout global constant definitions are listed in the following table.

LockTimeouts Global Constant Integer Value
LockTimeout_Immediate -1
LockTimeout_Infinite Max_Integer (#7FFFFFFF)
LockTimeout_Process_Defined -2 (use the process‑defined default lock request timeout)
LockTimeout_Server_Defined 0 (use the server-defined default)

You can specify a default lock timeout for a background process in the BackgroundProcessServerTimeout parameter in the [JadeClient] and [JadeServer] sections of the Jade initialization file. The background process lock timeout is specified in milliseconds, with the default value of 30000 (that is, 30 seconds).

You should not change the BackgroundProcessServerTimeout parameter value unless the background process is having locking problems. Before you increase this value, examine the application to determine which objects are being locked and whether locks are being held for too long. For example, new nodes cannot sign on if the system.nodes dictionary is locked by the application. It is better to change the application to minimize the locking of system collections.