pike.git / lib / modules / Sql.pmod / pgsql_util.pmod

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1:   /*    * Some pgsql utility functions.    * They are kept here to avoid circular references.    */      //! The pgsql backend, shared between all connection instances. - //! It even runs in non-callback mode. + //! It runs even in non-callback mode in a separate thread. + //! + //! @note + //! Callbacks running from this backend directly determine the latency + //! in reacting to communication with the database server; so it + //! would be prudent not to block in these callbacks.      #pike __REAL_VERSION__   #require constant(Thread.Thread)      #include "pgsql.h"    - protected Thread.Mutex backendmux = Thread.Mutex(); + //! The instance of the pgsql dedicated backend.   final Pike.Backend local_backend = Pike.SmallBackend(); -  +  + protected Thread.Mutex backendmux = Thread.Mutex();   protected int clientsregistered;      multiset cachealways=(<"BEGIN","begin","END","end","COMMIT","commit">);   Regexp createprefix    =Regexp("^[ \t\f\r\n]*[Cc][Rr][Ee][Aa][Tt][Ee][ \t\f\r\n]");   protected Regexp dontcacheprefix    =Regexp("^[ \t\f\r\n]*([Ff][Ee][Tt][Cc][Hh]|[Cc][Oo][Pp][Yy])[ \t\f\r\n]");   protected Regexp execfetchlimit    =Regexp("^[ \t\f\r\n]*(([Uu][Pp][Dd][Aa]|[Dd][Ee][Ll][Ee])[Tt][Ee]|\   [Ii][Nn][Ss][Ee][Rr][Tt])[ \t\f\r\n]|\
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:41:    PD("Starting local backend\n");    while(clientsregistered) // Autoterminate when not needed    local_backend(4096.0);    PD("Terminating local backend\n");    lock=0;    looponce=clientsregistered;    }    } while(looponce);   }    + //! Registers yourself as a user of this backend. If the backend + //! has not been started yet, it will be spawned automatically.   final void register_backend() {    if(!clientsregistered++)    Thread.Thread(run_local_backend);   }    -  + //! Unregisters yourself as a user of this backend. If there are + //! no longer any registered users, the backend will be terminated.   final void unregister_backend() {    --clientsregistered;   }      final void throwdelayederror(object parent) {    if(mixed err=parent._delayederror) {    parent._delayederror=UNDEFINED;    if(stringp(err))    err=({err,backtrace()[..<2]});    throw(err);