B.59. MacroExclusive()

Executes a previously defined macro but allows only a single instance of the macro to execute at any given point in time.
MacroExclusive(macroname[,arg1[,arg2[,...]]])
Executes - same as Macro() - a macro defined in macro-macroname, by handing the channel over to the s extension in the macro and returning after the macro has finished running, but allows only a single instance to run at any given time! If the same macro is called at the same time from elsewhere in the dialplan, this second instance must wait until the first instance has completed.
The called extension, context and priority are passed to the macro in the variables ${MACRO_EXTEN}, ${MACRO_CONTEXT} and ${MACRO_PRIORITY}. The arguments are passed to the macro in ${ARG1}, ${ARG2}, and so on.
Macro() returns -1 if any step in the macro returns -1, otherwise it returns 0. If the variable ${MACRO_OFFSET} is set when the macro finishes, the application will continue executing at priority n+1+MACRO_OFFSET if it exists, otherwise it will continue at n+1.
If Goto() is called from within the macro, macro execution ends and the call continues in the priority specified in Goto().
; define a macro that counts down from the provided value:
[macro-countdown]
exten => s,1,Set(COUNT=${ARG1})
exten => s,n,While($[ ${COUNT} > 0])
exten => s,n,SayNumber(${COUNT})
exten => s,n,Set(COUNT=$[ ${COUNT} - 1 ])
exten => s,n,EndWhile()

[default]
exten => 123,1,MacroExclusive(countdown,3)   ; call the macro "countdown" with ARG1=3
exten => 124,1,MacroExclusive(countdown,5)   ; call the macro "countdown" with ARG1=5

Note

Internal help for this application in Asterisk 1.4:
  -= Info about application 'MacroExclusive' =- 

[Synopsis]
Exclusive Macro Implementation

[Description]
  MacroExclusive(macroname|arg1|arg2...):
Executes macro defined in the context 'macro-macroname'
Only one call at a time may run the macro.
(we'll wait if another call is busy executing in the Macro)
Arguments and return values as in application Macro()
diff output to internal help in Asterisk 1.2:
-- not available in Version 1.2 --