Steve Baker (steve++at++mred.bgm.link.com)
Wed, 16 Apr 97 08:36:55 -0500
> I am new at C++ and have a question concerning the PF shared arena. How do I
> setup my user classes so they are defined in the pfsharedarena when the
> operator new is used or deleted from the pfsharedarena when the operator delete
> is called? Or is there another correct way of doing this? Any help or simple
> examples would be greatly appreciated.
The basic mechanism is to overload 'operator new' and 'operator delete' for
all classes that you want to place in shared memory.
One possible way to do this is to use something like:
/*
This class is designed as an abstract base class which ensures that
all objects of derived classes are placed into shared memory using
pfMalloc() and removed again using pfFree().
*/
class Shared_Memory_Object
{
public:
void *operator new ( size_t x )
{
return ( x == 0 ) ? NULL : pfCalloc ( 1, x, pfGetSharedArena () ) ;
}
void operator delete ( void *p )
{
if ( p != NULL )
pfFree ( p ) ;
}
} ;
Then you can say things like:
class MyClass : public Shared_Memory_Object
{
.
.
.
} ;
And then, anything declared using that class will be in shared memory.
At one time, there was a problem with doing this in IRIX's C++ compiler if
you delared an array of 'MyClass'. The compiler would (incorrectly) use
the default 'operator new' and 'operator delete' for arrays.
Does anyone know if that was ever fixed?
Steve Baker 817-619-1361 (Vox-Lab)
Hughes Training Inc. 817-619-8776 (Vox-Office/Vox-Mail)
2200 Arlington Downs Road 817-619-4028 (Fax)
Arlington, Texas. TX 76005-6171 Steve++at++MrEd.bgm.link.com (eMail)
http://www.hti.com (external) http://MrEd.bgm.link.com/staff/steve (intranet)
http://web2.airmail.net/sjbaker1 (external)
"You can't destroy the Earth - that's where I keep all my stuff!" - The Tick.
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:04 PDT