action:Semaphore_Lock
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| action:Semaphore_Lock [2016/06/16 05:45] – peternlewis | action:Semaphore_Lock [2022/10/31 01:42] (current) – [Macros Triggered by the User] peternlewis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | The //Semaphore actions// (Lock, Unlock and Reset) allow you to limit the execution of a sequence | + | ====== Semaphore Actions ====== |
| + | |||
| + | The //Semaphore actions// (Lock, Unlock and Reset) allow you to prevent (a) multiple triggers | ||
| + | |||
| + | ===== Background ===== | ||
| When you trigger a macro, the Keyboard Maestro Engine takes a copy of it and starts executing it. If you trigger another macro before the first one finishes, that will start executing as well - both will be executing more or less simultaneously. | When you trigger a macro, the Keyboard Maestro Engine takes a copy of it and starts executing it. If you trigger another macro before the first one finishes, that will start executing as well - both will be executing more or less simultaneously. | ||
| - | The normal case is that macros just all run simultaneously, | + | ==== Macros Triggered by the User ==== |
| - | Most macros | + | Although it is rare to have multiple |
| - | But there is another class of macros | + | Most macros are triggered |
| - | Occasionally there are cases where multiple macros | + | ==== Macros Triggered in the Background ==== |
| + | |||
| + | But there is another class of macros that operate in the background, most especially time triggered macros. Macros that are triggered independent of the UI and the user's awareness. Typically these will be written so as not to impact the user since the user won't be expecting them to run. So they might be things like backup scripts, or automatic download scripts, or the like. Things that happen in the background, or that wait for the user to be idle before doing stuff in the foreground. Often these sorts of macros run for a significant amount of time. | ||
| + | |||
| + | ===== Preventing Multiple Executions of One or More Macros ===== | ||
| + | |||
| + | Occasionally there are cases where multiple macros | ||
| + | |||
| + | **The //Semaphore actions// require a _Semaphore Name_, which uniquely identify each _Semaphore Lock_.** | ||
| + | |||
| + | **In order to prevent simultaneous executions (instances) of one or more macros that have _Semaphore Locks_ with the same _Semaphore Name_, do the following: | ||
| + | |||
| + | * Place a //Semaphore Lock// Action (using the same Semaphore Name) as the first action of each Macro that you wish to prevent executing simultaneously. | ||
| + | * The lock will remain in place, preventing the other macros from executing, until the current | ||
| + | * When the Semaphore is _unlocked_ the next macro instance in the queue will execute in First In First Out (FIFO) order. | ||
| + | * You can also cause all additional macro instances | ||
| - | This is a primary purpose of using a //Semaphore Lock// - just place one at the start of the sequence. | ||
| - | The //Semaphore actions// take a name, and different names can be used for different (independent) locks. | ||
| Semaphore Lock can be balanced by a Semaphore Unlock, but a Semaphore is implicitly unlocked when the macro that locked it completes. | Semaphore Lock can be balanced by a Semaphore Unlock, but a Semaphore is implicitly unlocked when the macro that locked it completes. | ||
| Line 35: | Line 52: | ||
| - [[https:// | - [[https:// | ||
| - | - [[https://www.google.fr/search?q=site: | + | - [[https://forum.keyboardmaestro.com/t/ |
| + | |||
| + | - [[https://forum.keyboardmaestro.com/ | ||
| + | |||
| + | - [[https:// | ||
action/Semaphore_Lock.1466055919.txt.gz · Last modified: by peternlewis
