Lock aFunctions

LOCK_ACQUIRE

LOCK_ACQUIRE(String lockName, String lockMode, String exceptionHandling[, String waitTime])

Acquires a specific lock to execute a process.

Arguments:
  • lockName (java.lang.String) – A name which will be assigned for lock.
  • lockMode (java.lang.String) – Parameter which says the mode of the acquired lock. Valid mode values are “SHARED” or “EXCLUSIVE”.
  • exceptionHandling (java.lang.String) – Parameter which says how to handle the execution in case any exception raised. Valid values are “EXCEPTION” OR “BOOLEAN”. A boolean “false” is returned in case of any exception in process if this parameter is “BOOLEAN”.
  • waitTime (java.lang.String) – (Optional) The time process should wait to acquire the lock. The time format is “hours:minutes:seconds[:milliseconds]”.
Return-type :

java.lang.Boolean

Returns:

Returns Boolean true if the lock is acquired or False if the parameter exceptionHandling is passed as “BOOLEAN”, throws exception if exceptionHandling is “EXCEPTION”.

Example:

=LOCK_ACQUIRE("SMOOTHIE", "EXCLUSIVE", "EXCEPTION", "0:0:2")

In the above example, the process will wait for 2 seconds to acquire the exclusive lock “SMOOTHIE” and an exception is thrown if it fails to acquire the lock in specified time.

LOCK_WAIT

LOCK_WAIT(String lockName, String lockMode, String exceptionHandling[, String waitTime])

Waits if a lock is busy, but does not permanently acquire the lock.

Internally afunction will wait and tries to acquire the lock. On failure based on exceptionHandling parameter returns false or throws exception. On success release the lock immediately so that the lock is set free for any other process to acquire.

Thus both LOCK_ACQUIRE and LOCK_WAIT are implemented almost the same way except that LOCK_WAIT immediately releases the acquired lock.

Arguments:
  • lockName (java.lang.String) – A name which will be assigned for lock.
  • lockMode (java.lang.String) – Parameter which says the mode of the acquired lock. Valid mode values are “SHARED” or “EXCLUSIVE”.
  • exceptionHandling (java.lang.String) – Parameter which says how to handle the execution in case any exception raised. Valid values are “EXCEPTION” OR “BOOLEAN”. A boolean “false” is returned in case of any exception in process if this parameter is “BOOLEAN”.
  • waitTime (java.lang.String) – (Optional) The time process should wait to acquire the lock. The time format is “hours:minutes:seconds[:milliseconds]”.
Return-type :

java.lang.Boolean

Returns:

Returns Boolean true if the lock gets acquired within the specified time or False if the parameter exceptionHandling is passed as “BOOLEAN”, throws exception if exceptionHandling is “EXCEPTION”.

Example:

=LOCK_WAIT("SMOOTHIE", "EXCLUSIVE", "EXCEPTION", "0:2:0")

In the above example, the process will wait for the exclusive lock “SMOOTHIE” for maximum 2 minutes. On failure an exception is thrown if the wait exceeds beyond the permissible time. On success release the lock immediately so that the lock is set free for any other process to acquire.

LOCK_RELEASE

LOCK_RELEASE(String lockName)

Release a specific lock to for the other processes to acquire the lock and execute.

Arguments:
  • lockName (java.lang.String) – The lock name which is released.
Return-type :

java.lang.Boolean

Returns:

Example:

=LOCK_RELEASE("SMOOTHIE")

In the above example, the lock “SMOOTHIE” is released.

LOCK_RELEASEALL

LOCK_RELEASEALL()
Release all the acquired locks.

Example:

=LOCK_RELEASEALL()

Table Of Contents

Previous topic

IO / File aFunctions

Next topic

Math aFunctions

This Page