Re: Module globals in a C++ extension

From: Date: Tue, 24 Jan 2012 20:33:50 +0000
Subject: Re: Module globals in a C++ extension
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9068@lists.php.net to get a copy of this message
On 01/23/2012 09:25 PM, Antony Dovgal wrote: > On 01/23/2012 11:10 PM, Kārlis Repsons wrote: >> Hi again, >> >> could someone post some info about writing extensions in C++ with object >> as a module global? (that is, regardless of the used MPM (or something >> else), make some object instance common for all running instances of the >> same extension) > > Why don't you just pass it when needed? > Or create the object, increase zval's refcount in order to keep it and > return it when needed? > Sound weird to me, but it's not C++ specific at all. Here's what's wrong (or part of it): by writing "module global" I meant a variable, which is common for all processes/threads, in which PHP extension code is being run. Think of some common resource, which must be initialized just once and accessed through a single class instance, no matter how the extension code is executed! (and that class instance may contain no zend engine structures) How should it be done? Any examples? > PECL/rar is in C++ (more or less). Thanks!

« previous php.pecl.dev (#9068) next »