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/09/02 11:34] – add forum link alain | 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 | + | ==== Macros Triggered by the User ==== |
| + | |||
| + | Although it is rare to have multiple macros triggered at the same time, the normal | ||
| + | |||
| + | Most macros are triggered explicitly manually, and typically the user waits for them to complete before they trigger another macro. So 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 can be triggered, or the same macro triggered again, before the other macros complete. This can sometimes cause a problem, which needs to be prevented. | ||
| - | Most macros are executed explicitly by the user, and the user expects them to do their thing and then the user goes on to the next thing, so macros like this will rarely run at the same time since the user is highly aware of what is going on. | + | **The //Semaphore actions// require a _Semaphore Name_, which uniquely identify each _Semaphore Lock_.** |
| - | 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 wont 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. | + | **In order to prevent simultaneous executions (instances) |
| - | Occasionally there are cases where multiple macros are running | + | * Place a //Semaphore Lock// Action (using the same Semaphore Name) as the first action of each Macro that you wish to prevent executing |
| + | * The lock will remain in place, preventing the other macros from executing, until the current macro instance | ||
| + | * 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 39: | Line 56: | ||
| - [[https:// | - [[https:// | ||
| - | - [[https://www.google.fr/search?q=site: | + | - [[https://forum.keyboardmaestro.com/ |
action/Semaphore_Lock.1472816098.txt.gz · Last modified: by alain
