Non-blocking version of Gosub command

Within my dialplan there is a situation that arises where I would like to loop through an array of numbers, assign each individual number to an inheritable channel variable then call Gosub to go to a context where an Originate occurs.

So far I can only do this in blocking fashion. Is there some command or technique to allow my loop to call several instances of the same context multiple times simultaneously? Or will I have to create new channels for each one?

Try using the dial application with the Local channel:

Dial(Local/ext1@somecontext&Local/ext2@somecontext&…)

this should start processing in parallel.

Thanks for the tip. So if I have a simple setup like below in which I try to use Local in a Dial command to start parallel work:

[broadcast]
;***
; NOTES
;   This receives a tilde delimited list of broadcast targets and 
;   the path of a sound file.  Each target is then called and
;   Playback is used to play a selected message (${target})
;***
  exten => s, 1, NoOp(=-=-=- ${EXTEN}@${CONTEXT} -=-=-=)
  exten => s, n, Set(i=0)
  exten => s, n, Set(_file=${soundfilepath})
  exten => s, n, While($[${i} < ${targetcount}])
  exten => s, n, Set(i=$[${i}+1])
  exten => s, n, Set(_target=${CUT(targets,"~",${i})})
  exten => s, n, Dial(Local/s@call-target,,)
  exten => s, n, EndWhile
  exten => s, n, Hangup()

[call-target]
  exten => s, 1, NoOp(=-=-=- ${EXTEN}@${CONTEXT} -=-=-=)
  exten => s, n, Originate(${target},app,Playback,${file})
  exten => s, n, Hangup()

In my scenario the entry point is broadcast, and soundfileath="/some/path/to/a/soundfile.WAV" and targets=“SIP/Some_Ext_000@someVoipHost~SIP/8665551234@toPstn”. So this setup does work, in that both parties are called and the correct sound file is played upon pick up.

The problem is that it is still blocking at s@call-target:2. The second party’s device does not start ringing until Some_Ext_000 picks up. I understand Originate is necessarily blocking, but I thought that by use Dial(Local/ …) I had invoked call-target on a new, parallel channel. I’m sure it’s terribly obvious but what am I missing?

Thanks.

You get parellel processing when you use more than one target of the Dial application.
There is no magic, you need to Dial() all of your targets in one shot.

Okay, doing them all in the same Dial() worked.