Re: PIKE_MODULE_INIT/EXIT in a normal pgsql.pike file
"Stephen R. van den Berg" <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
Stephen R. van den Berg wrote: >However, in order to get this flying I basically need to run >a separate pgsql backend. Currently I simply start up a new one in a separate >thread for every connection to the database. >But, these could be shared by all pgsql connections. >So, is there some kind of PIKE_MODULE_INIT/EXIT or C-static equivalent >which I could use to make sure that I only create at most one thread >for this? Despite the overwhelming response to this question, I tried to investigate on my own, and basically I came up with (drumroll): getenv()/putenv() It's ugly, but it seems to be the only way to have some kind of global state over which different threads can meet and sync up. However, I'd need a way to serialise a reference to an object (a shared backend, to be precise). Any ideas? Or can we have some kind of Master.get() and Master.set() equivalent to the Thread.Local set which would fill this gap? -- Stephen.