[asterisk-users] global variables and updates

Lee Jenkins lee at datatrakpos.com
Sat Jul 28 10:14:56 CDT 2007


Watkins, Bradley wrote:
> The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.
> 
>> From: asterisk-users-bounces at lists.digium.com 
>> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of 
>> Julian Lyndon-Smith
>> Sent: Saturday, July 28, 2007 5:18 AM
>> To: asterisk-users at lists.digium.com
>> Subject: [asterisk-users] global variables and updates
>>
>> Sorry if this appears twice - I originally sent it nearly 18 
>> hours ago 
>> and never saw it ..
>>
>> I have a need to have a unique integer number that can be used by a
>> dynamic meetme room (I am wanting to redirect a call into a meeting 
>> room, and need a unique number to make sure I don't put two people 
>> together !)
>>
>> I was going to use a global variable ${NEXTMEETME}, and add one every 
>> time I redirect.
>>
>> Is the changing of a global variable atomic ? That is, if I 
>> have two or 
>> more channels being redirected at the same time, and they all execute
>>
>> exten => _X.,n,Set(NEXTMEETME=${MATH(${NEXTMEETME}+1,i)})
>> exten => _X.,n,Set(MYMEETME=${NEXTMEETME})
>>
>> if NEXTMEETME is initially 0, would channel A get MYMEETME as 
>> 1, channel 
>> B get 2 and channel C get 3, even if they execute the dialplan at the 
>> same time ?
>>
> 
> The changing of variables is not atomic as would hope, but there is a
> solution for you.  Look the application MacroExclusive.  Put your Set to
> increment the global variable inside of a macro and call it using this,
> and you will get the behavior you desire.  One caveat, however, is that
> you will want as little logic as possible inside of this macro.
> MacroExclusive will block all other calls to this macro until the first
> one exits.  But this is not an issue if all you are doing is a quick
> var++ and then leaving.
> 

That's a very nice feature.  A quick Google search on the wiki didn't 
turn up any topics.  Does it queue subsequent calls or just block them 
and then logic in the dialplan must be used against a return value?

---
Warm Regards,

Lee





More information about the asterisk-users mailing list