LassoScript Utility
Basics Browse Detail

[Thread_Atomic] ... [/Thread_Atomic]

Tag Link [Thread_Atomic] ... Category Threads
Type Container Source Available No
Support Preferred Version 8.5
Change New Data Source Any
Output Type None Security None
Implementation Internal Sets Lasso 8.5


[Thread_Atomic] ... [/Thread_Atomic] is used to designate an atomic section of Lasso code. The opening [Thread_Atomic] tag is passed a reference to a variable which is used to constrain the execution of the atomic section. Only one instance of the code is allowed to run concurrently. If another Lasso page (or thread) attemps to run an atomic section that references the same variable then it will block until the first thread has completed.

Atomic sections should be used to control access to shared resources. For example, if a section of code is going to modify a global variable, and must be ensured that no other code is going to modify the global variable until it has completed, it can use [Thread_Atomic] using the global variable as its reference to ensure that it has exclusive access.

Note that the use of [Thread_Atomic] is voluntary. If two Lasso pages use [Thread_Atomic] with the same reference then they are guaranteed that only one atomic section will execute at a time. However, a rogue Lasso page could access the same resources without calling [Thread_Atomic]. Good programming practice requires using [Thread_Atomic] each time the shared resource is accessed.

Custom tags and custom member tags can also be defined to run atomically using the -Atomic keyword. See the description under the [Define_Tag] ... [/Define_Tag] tag for more details.


[Thread_Atomic: (Global: 'Shared Global')]
... atomic section which uses shared global ...


Required Parameters
Reference The referenced variable is used to constrain concurrent execution of the atomic section. The variable itself is not modified.


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