[Freeswitch-dev] Additional support for synchronization functions
David Swardstrom
dswardstrom at remotelink.com
Tue Jun 1 14:00:36 PDT 2010
I got so involved in getting the proposed optional third parameter to
setGlobalVariable() that I did not consider all of the possibilities.
Using the change along with getGlobalVariable() is ok for data that
would only change or for data that does not need to be completely unique.
I also have a need to have a global counter that can both be incremented
and decremented. This counter is designed to give me more control over the
number of calls than the current mod_limit will provide.
This would be used during a period where they may be several calls
either entering the system, exiting the system, or both.
It would be nice to have routines that would just increment or decrement
safely. They would be much faster.
I have spent the last couple of years working with Visual Studio and C++.
The natural solution I would take in this situation would be to use
InterlockedIncrement() and InterlockedDecrement().
In this environment I don't think I want to propose this.
What I would like to propose is the following set of routines
(using JavaScript notation):
// Initialize the counter to a specified value
initGlobalCounter(string name of variable, initial value);
// Add a value to the global counter
addGlobalCounter(string name of variable, value to add);
// Subtract a value from the global counter
reduceGlobalCounter(string name of variable, value to subtract);
I am open to suggestions as to names of the routines.
Even though all I need (now) is increment and decrement, since
the code will need to use the Global Variable Mutex locks, it
might as will be more general.
Regards,
Paul David Swardstrom
More information about the FreeSWITCH-dev
mailing list