Re: [info-performer] Allocating classes from shared memory

Date view Thread view Subject view Author view

From: Kumar Iyer (iyer++at++ict.usc.edu)
Date: 09/29/2003 11:59:28


Using the "placement new" form can also be useful, if you wish to keep
your class hierarchy free of explicit dependencies to pf, but still
allocate your classes in pf memory -
e.g.

class T {
(...)
};

void *mem=pfMalloc(sizeof(T), pfGetSharedArena());
T *obj=new(mem) T();

-k.

On Mon, 2003-09-29 at 04:28, MLM Veraart wrote:
> Or use
>
> class CTriangle
> {
> PFSTRUCT_DECLARE
> public:
>
> };
>
> It will overload the new and delete operators of your class
>
> Mario
>
> Goncalo Nuno Moutinho De Carvalho wrote:
> >
> > Hey,
> >
> > Deriving from pfMemory or pfObject should do the trick.
> >
> > Cheers,
> >
> > Goncalo
> >
> > -----Original Message-----
> > From: Dimi <christop++at++fhw.gr>
> > To: info-performer++at++sgi.com
> > Date: Wed, 24 Sep 2003 10:19:51 +0300
> > Subject: [info-performer] Allocating classes from shared memory
> >
> > Hi,
> > I currently have a library which stores geometric objects.
> > Each object say a triangle is represented by a class say CTriangle.
> > Each class has its own constructors/destructors and the data (vertices,
> > texture coordinates and others) as member data.
> > I used to allocate arrays of classes using new like this
> > for (i=0;i<numofcalsses;i++)
> > array[i] = new CTriangle;
> >
> > I run into problems when I tried to use this library on machines with
> > more than 1 processors.
> > When I set up APPCULLDRAW mode (all in one process)the library works
> > fine.
> > But as soon I use any other mode which happens on machines with more
> > than 1 processor,
> > I get a core dump.
> >
> > I suspect that I have to allocate any memory from the shared arena.
> > Until now I used mostly struct
> > and used the pfMalloc to do that. How can I allocate memory for whole
> > classes from the shared arena?
> >
> > Thanks
> > Dimi
> >
> > -----------------------------------------------------------------------
> > List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> > Open Development Project: http://oss.sgi.com/projects/performer/
> > Submissions: info-performer++at++sgi.com
> > Admin. requests: info-performer-request++at++sgi.com
> > -----------------------------------------------------------------------
> >
> > -----------------------------------------------------------------------
> > List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> > Open Development Project: http://oss.sgi.com/projects/performer/
> > Submissions: info-performer++at++sgi.com
> > Admin. requests: info-performer-request++at++sgi.com
> > -----------------------------------------------------------------------
>
> --
> ------------------------------------------------------------------------------
> The disclaimer that applies to e-mail from
> TNO Physics and Electronics Laboratory
> can be found on: http://www.tno.nl/disclaimer/email.html
> ------------------------------------------------------------------------------
>
> -----------------------------------------------------------------------
> List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
> -----------------------------------------------------------------------


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Sep 29 2003 - 12:03:04 PDT