shared memory primitives module

From: Date: Fri, 10 Jan 2003 20:33:29 +0000
Subject: shared memory primitives module
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-12251@lists.php.net to get a copy of this message
Hello, I have written few classes that wraps the sysvshm and sysvsem modules. Classes : 1)CSemaphore . Methods : acquire() and release() . The initialization is done in the constructor. 2)CSHMVar Methods : get_var() and put_var() . The initialization is the constructor. 3)CProtectedShmVar Methods :start_section(), end_section(), set_val(), get_val() . Initialization in the constructor. This class is used to acces Shm var but the access is protected with a semaphore. start_section() has to be callen to start the critical section. end_section() finishes the critical section. While in critical section the user is permitted to access the shm variable. 4)CCodeLoadProtector Methods : increase_load(), decrease_load(), null_counter_value(), get_counter_value(). Initialization in the constructor. This class is an wrapper for the shm primitives from the php modules but uses the classes mentioned above to perform its duty. It may be used to protect a server from overload. Thus only limited instances of a script protected with this class will operate. Of course a script is executed on every request but it's the programmer's duty to place the code for protection as much as possible in the beggining of the script. The method increase_load() has to be callen. If it returns FALSE that means that the limit of running scripts is reached (so the script has to terminate). If TRUE is returned the script may continue but before it's end decrease_load() has to be callen. The best way to perform this is by registering shutdown function to perform that. If there is a interest I will provide the source code to be adapted for PEAR. Regards, Andrey

« previous php.pear.dev (#12251) next »