Lock
With Lock commands a package can exclusive enter a specific execution area.
- Locks can be set on condition.
- Locks have a name - the lock name must be file name compatible
- To request a lock takes at least 1-2 seconds
- After a release it takes at least 1-2 seconds to process the next waiting package execution.
- Locks are processed in order - first in - first out
- The lock owner is not interrupted - any following lock_request throws an error after max 10 seconds waiting.
- The 10 seconds waiting time count from the call to lock_request
- Locks can be used across packages - they are environment specific
- always use fixed lock names - do not calculate them - do not use id's of external entities.
- max lock name length is 10 characters
- EACH LOCK HAS TO BE RELEASED WITHIN 10 SECONDS
- A LOCK OLDER THAN 10 SECONDS CAN LEAD TO PARALLEL EXECUTION!
The following functions are deprecated - do not use
lock_request
Requests an exclusive lock for a specific lock name. The package execution stops until this keyword is free for use.
A lock can be maximum 10 seconds old. The execution that owns the lock is not interrupted. But any following lock request will fail after 10 seconds if the lock is not released.
A lock with a specific name can be requested only once in one package execution.
All owned locks are released at the end of a package.
The lock name must fit file name requirements.
lock_request("lock_name");
Example :
const lock_name = "Save_area";
lock_request(lock_name);
sleep(1000); // do something exclusive running
lock_release(lock_name);
lock_release
Releases an exclusive lock for a specific lock name. Further package executions that wait for the lock will be started in order.
A lock can be maximum 10 seconds old. The execution that owns the lock is not interrupted. But any following lock request will fail after 10 seconds if the lock is not released.
All owned locks are released at the end of a package.
The lock name must fit file name requirements.
lock_release("lock_name");
Example :
const lock_name = "Save_area";
lock_request(lock_name);
sleep(1000); // do something long running
lock_release(lock_name);
request_lock
deprecated - do not use
Request a lock for a specific keyword. The package execution stops until this keyword is free for use.
It is tried 20 times in 500ms steps before a error returns.
A lock can be maximum 8 seconds old. Use refresh_lock to refresh the timer of a lock.
All locks are released at the end of a package.
The lock name must fit file name requirements.
let lock = request_lock("lock_name");
Example :
let lock = request_lock("Save_area_name");
sleep(1000); // do something long running
refresh_lock(lock); // refresh the lock timeout
sleep(1000); // do something long running
release_lock(lock);
release_lock
deprecated - do not use
Release a lock.
release_lock(lock_object);
Example :
let lock = request_lock("Save_area_name");
sleep(1000); // do something long running
refresh_lock(lock); // refresh the lock timeout
sleep(1000); // do something long running
release_lock(lock);
refresh_lock
deprecated - do not use
Refresh a locks timeout.
refresh_lock(lock_object);
Example :
let lock = request_lock("Save_area_name");
sleep(1000); // do something long running
refresh_lock(lock); // refresh the lock timeout
sleep(1000); // do something long running
release_lock(lock);
clear_lock
deprecated - do not use
Clear a lock regardless of its state or owner.
Use this command with care - it can cause damage in other packages.
clear_lock("lock_name");
Example :
clear_lock("Save_area_name");