User Tools

Site Tools


action:Semaphore_Lock

**This is an old revision of the document!**

The Semaphore actions (Lock, Unlock and Reset) allow you to limit the execution of a sequence of actions.

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, and you rarely have multiple macros running at the same time.

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.

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.

Occasionally there are cases where multiple macros are running simultaneously (or the same macro is running multiple times) and care needs to be taken that the sequences of actions are not intermixed.

This is a primary purpose of using a Semaphore Lock - just place one at the start of the sequence. The lock will remain in place (and any other macros that try to execute that action will have to wait) until the end of the macro, or until you execute a Semaphore Unlock or Semaphore Reset action.

The Semaphore actions take a name, and different names can be used for different (independent) locks.

See Also


Actions

Forum

action/Semaphore_Lock.1462184164.txt.gz · Last modified: 2016/05/02 06:16 by alain