Re: [PHP4BETA] persistent connection api [was Re: [PHP4BETA] how does the ZTS work / where are the mutexes?]

From: Date: Wed, 18 Aug 1999 13:14:52 +0000
Subject: Re: [PHP4BETA] persistent connection api [was Re: [PHP4BETA] how does the ZTS work / where are the mutexes?]
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-3542@lists.php.net to get a copy of this message
> hi Sasiha;-) Never edit the header of your emails without double checking your changes. ;-) > > i like the api-idea - but what list-id are we talking about? zeev, as far > as i can see it there's no such thing like a all threads global list, > right? > > so what shoud we do? The maximum scope. In a threaded environment this would be across multiple threads. In Apache etc. this would be a single process. > there's another problem: we might not be able to use the same persistent > entry twice at the same time in 2 threads - so that needs to be taken care > of. we could remove or lock the entry from the thread-global list for the > time we use it (in the remove case put it back when the requst ends)? Yes. I just wanted to propose a start. We could implement a reference counter on every resource and introduce another call: void release_resource(long id); Decreases the reference count of resource `id.' And some changes: long acquire_resource(char *modname, char *key, void *(*create)(char *key), void (*destruct)(char *key, void *data), int maxref); Checks whether a resource with a specific `key' and a reference count less than `maxref' exists in a persistent list which is valid across the largest accessible scope. If such a resource is found, the reference count is increased, and the resource id is returned. If such a resource is not found, a new resource is created using the `create' function. If the result of that function is not NULL, the resource is inserted into the persistent list, its reference count is set to 1, and its id is returned. If no resource is found and the creation of a new one failed, the function returns -1. (I had a more complex API in mind initially, but I trimmed it down enormously, just to avoid overdesign.) -- Regards, Sascha Schumann Consultant

« previous php.version4 (#3542) next »