Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 79847 invoked from network); 10 Jul 2008 11:16:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jul 2008 11:16:56 -0000 Received: (qmail 89768 invoked by uid 500); 10 Jul 2008 11:16:52 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 89718 invoked by uid 500); 10 Jul 2008 11:16:51 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 89694 invoked by uid 99); 10 Jul 2008 11:16:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2008 04:16:51 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sorinm@gmail.com designates 74.125.46.154 as permitted sender) Received: from [74.125.46.154] (HELO yw-out-1718.google.com) (74.125.46.154) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2008 11:15:57 +0000 Received: by yw-out-1718.google.com with SMTP id 6so1327735ywa.84 for ; Thu, 10 Jul 2008 04:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=B59Nyi0mJ/JD/Klol31KDNX9/toxtByPqIZ2s6x3XO0=; b=WeVEyOE9ukiC3hE5IInlUTY9i+DscsyVn9oKstE97ANZU/8qebhlTdg5pngCuzUqRB jlVbSEKZPAsdA+DkIoTup/ygrUdBszLzONX4WxIRuM+gM3qt4MQPgdt7fw/FqOHQyX+E rqBOh2pCr5frMMO6oEHAaN263+fWgPsTGhOno= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=cvhs71S80ALQFk0XceC5X3PrH3oJ/oL8xPO1ly+OBgm3cezWbsDvZJqmpu+ap6AJJa CjsmvZbver3Z+G/VL+rXgneHzVZvxC+jn8AQ2eV605h7PgoRBLgLdUmo2hJquINRUdAQ 8wHrZOe71GM2nDXQCPNBBQa2J6PoKOnYbaRoI= Received: by 10.114.157.1 with SMTP id f1mr10688878wae.14.1215688574883; Thu, 10 Jul 2008 04:16:14 -0700 (PDT) Received: by 10.115.23.13 with HTTP; Thu, 10 Jul 2008 04:16:14 -0700 (PDT) Message-ID: <20170a030807100416p2b23899fg7884a4410e55a037@mail.gmail.com> Date: Thu, 10 Jul 2008 13:16:14 +0200 From: "Sorin Manolache" To: modules-dev@httpd.apache.org Subject: Re: Instance a c++ object on Apache shared memory In-Reply-To: <18379811.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <18377523.post@talk.nabble.com> <20170a030807100201u3ee38ecdk1d1e8e78ef0f1e09@mail.gmail.com> <18379811.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Jul 10, 2008 at 12:17, lusob wrote: > > Hello, and thanks for the example! > My class has another class as data member (instead a struct). How can I > allocate it in shared memory? As far as I know you cannot. But maybe I'm wrong. S > Sorin Manolache wrote: >> >> On Thu, Jul 10, 2008 at 09:41, lusob wrote: >>> >>> Hello, >>> I'm developing an apache c++ module and I need to create a global >>> persistent >>> object for all the processes. >> >> Hi, >> >> I'm doing something similar. >> >> I declare >> >> static MyClass *my_object >> >> globally in your module c++ file. >> >> >> Then I hook post_config. There, I do >> >> MyClass *my_object = new MyClass(config_pool); >> >> >> In the constructor of MyClass I create a shared memory segment: >> >> class MyClass { >> public: >> MyClass(apr_pool_t *config_pool) { >> apr_shm_create(&m, sizeof(MyStruct), 0, config_pool); >> shared = apr_shm_baseaddr_get(m); >> // when config_pool is destroyed, the shared memory segment and >> this object are destroyed too >> apr_pool_cleanup_register(config_pool, this, (apr_status_t >> (*)(void *))my_cleanup, NULL); >> init(shared); >> } >> ~MyClass() { >> tear_down(shared); >> apr_shm_destroy(m); >> } >> private: >> apr_shm_t *m; >> MyStruct *shared; >> }; >> >> apr_status_t my_cleanup(MyClass *obj) { >> delete obj; >> } >> >> -- >> S >> >> > > -- > View this message in context: http://www.nabble.com/Instance-a-c%2B%2B-object-on-Apache-shared-memory-tp18377523p18379811.html > Sent from the Apache HTTP Server - Module Writers mailing list archive at Nabble.com. > >