[asterisk-users] global variables and updates
Lee Jenkins
lee at datatrakpos.com
Sat Jul 28 08:08:23 CDT 2007
Julian Lyndon-Smith wrote:
> 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 ?
>
Someone more knowledgeable about Asterisk than I can correct me, but I
would look at it from the perspective any development environement:
Global variables are typically bad in a threaded environment without
some form of queuing/locking/critical section functionality to avoid
collisions.
If I needed a globally unique, sequential number, I'd push it out to
AGI/FastAGI so I could use a language with support for locking/queuing.
A DB like MySQL or FirebirdSQL would easily handle this need as you
know, but then is the overhead of establishing DB connections worth it
for simply getting a incremented int?
--
Warm Regards,
Lee
More information about the asterisk-users
mailing list