LassoScript Utility
Basics Browse Detail

[Thread_RWLock]

Tag Link [Thread_RWLock] Category Threads
Type Substitution Source Available Yes
Support Preferred Version 6.0
Change Unchanged Data Source Any
Output Type Thread_RWLock Security Tag
Implementation LDML Sets Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0

Description

Creates a lock that can be used to control concurrent access to a shared resource such as a global server-wide variable or a file. This lock allows an unlimited number of process to read, but only one process can write to the shared resource.

A read lock can be established using the [Thread_RWLock->ReadLock] tag or released using the [Thread_RWLock->ReadUnlock] tag. A write lock can be established using the [Thread_RWLock->WriteLock] tag or released using the [Thread_RWLock->WriteUnlock] tag.

A read/write lock allows many concurrent read accesses. However, if a write lock is requested it must wait until all current read accesses have been released before it is granted. Once a write lock is granted no read or write access will be granted until it is released.

Note: The use of thread tools is entirely voluntary. There is nothing in Lasso that prevents access to the same shared resource, but the diligent use of the thread tools will ensure predictable results.

Syntax

[Global: 'myLock' = (Thread_RWLock)]

[if: $myLock->(ReadLock: 1000)]
...
[$myLock->(ReadUnlock)]
[/If]

[if: $myLock->(WriteLock: 1000)]
...
[$myLock->(WriteUnlock)]
[/If]

Parameters

No Parameters Required.

Examples

See the Lasso 8 Language Guide for examples of how to use this tag.