Smith, Jeff W. (jsmith++at++smtpgate.gstone.com)
Fri, 24 Feb 1995 16:54:30 -0800
-- Jeff WS
jsmith++at++gstone.com
----------
From: Martin Roth
To: marrou
Cc: info-performer
Subject: Re: shared memory object classes
Date: Friday, February 24, 1995 4:15PM
Lance R Marrou wrote:
> I am curious if it is possible to use the operator new to allocate an
object
> class in shared memory. I tried most (if not all) combinations like:
>
> po = ::new(sizeof(printobj),pfGetSharedArena()) printobj();
> po = new(sizeof(printobj),pfGetSharedArena()) printobj();
> po = new(pfGetSharedArena()) printobj();
>
> These were just some simple test cases, I have much more complicated
classes
> in mind. What seems to work is this:
>
> po = (printobj *)pfMalloc(sizeof(printobj),pfGetSharedArena());
>
> But then I need a fake constructor to call after allocation.
Hi Lance,
I'm doing this in my application through overloading of the new and delete
operators of all my classes:
void *operator new(size_t sz, void *a) { return pfMalloc(sz, a);
}
void *operator new(size_t sz) { return pfMalloc(sz, NULL); }
void operator delete(void *addr) { pfFree(addr); }
Allocating an object in shared memory is done through:
obj = new(pfGetSharedArena()) Object();
and of course the constructor is called as always.
Does this help?
Martin
____________________________________________________________________________
___
_
/| /|) S. H. Martin
Roth
/ |/ |\OTH Student in Computer
Science
ETHZ, Swiss Federal Institute of Technology Zuerich email:
sroth++at++iiic.ethz.ch
UniZh, University of Zuerich email:
roth++at++ifi.unizh.ch
------ Message Header Follows ------
Received: from realityone.gstone.com by smtpgate.gstone.com
(PostalUnion/SMTP(tm) v2.1.3 for Windows NT(tm))
id AA-1995Feb24.161516.1024.2180; Fri, 24 Feb 1995 16:15:17 -0800
Received: from SGI.COM by realityone.gstone.com via SMTP
(931110.SGI/930416.SGI.AUTO)
for jsmith++at++smtpgate.gstone.com id AA26854; Fri, 24 Feb 95 16:15:13
-0800
Received: from holodeck.asd.sgi.com by sgi.sgi.com via ESMTP
(950221.405.SGI.8.6.10/910110.SGI)
id PAA08924; Fri, 24 Feb 1995 15:55:17 -0800
Received: by holodeck.asd.sgi.com (940816.SGI.8.6.9/940406.SGI.AUTO)
for info-performer-dist id OAA00016; Fri, 24 Feb 1995 14:50:56 -0800
Received: from giraffe.asd.sgi.com by holodeck.asd.sgi.com via SMTP
(940816.SGI.8.6.9/940406.SGI.AUTO)
for <info-performer++at++holodeck.asd.sgi.com> id OAA00013; Fri, 24 Feb 1995
14:50:51 -0800
Received: from sgi.sgi.com by giraffe.asd.sgi.com via SMTP
(920330.SGI/920502.SGI)
for info-performer++at++holodeck.asd.sgi.com id AA08848; Fri, 24 Feb 95
14:50:29
-0800
Received: from josef.ifi.unizh.ch by sgi.sgi.com via SMTP
(950221.405.SGI.8.6.10/910110.SGI)
for <info-performer++at++sgi.com> id OAA29037; Fri, 24 Feb 1995 14:50:27
-0800
Message-Id: <199502242250.OAA29037++at++sgi.sgi.com>
Received: from ifi.unizh.ch by josef.ifi.unizh.ch
id <00418-0++at++josef.ifi.unizh.ch>; Fri, 24 Feb 1995 23:50:45 +0100
To: marrou++at++vsl.ist.ucf.edu
Subject: Re: shared memory object classes
Cc: info-performer++at++sgi.com
Date: Fri, 24 Feb 1995 23:50:45 +0100
From: Martin Roth <roth++at++ifi.unizh.ch>
Sender: roth++at++ifi.unizh.ch
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:00 PDT