Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Friends
morkPool Class Reference

#include <morkPool.h>

Inheritance diagram for morkPool:
Inheritance graph
[legend]
Collaboration diagram for morkPool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void CloseMorkNode (morkEnv *ev)
virtual ~morkPool ()
 morkPool (const morkUsage &inUsage, nsIMdbHeap *ioHeap, nsIMdbHeap *ioSlotHeap)
 morkPool (morkEnv *ev, const morkUsage &inUsage, nsIMdbHeap *ioHeap, nsIMdbHeap *ioSlotHeap)
void ClosePool (morkEnv *ev)
mork_bool IsPool () const
void NonPoolTypeError (morkEnv *ev)
voidoperator new (size_t inSize, nsIMdbHeap &ioHeap, morkEnv *ev) CPP_THROW_NEW
voidoperator new (size_t inSize) CPP_THROW_NEW
morkHandleFace * NewHandle (morkEnv *ev, mork_size inSize, morkZone *ioZone)
void ZapHandle (morkEnv *ev, morkHandleFace *ioHandle)
morkRowNewRow (morkEnv *ev, morkZone *ioZone)
void ZapRow (morkEnv *ev, morkRow *ioRow, morkZone *ioZone)
morkCellNewCells (morkEnv *ev, mork_size inSize, morkZone *ioZone)
void ZapCells (morkEnv *ev, morkCell *ioVector, mork_size inSize, morkZone *ioZone)
mork_bool AddRowCells (morkEnv *ev, morkRow *ioRow, mork_size inNewSize, morkZone *ioZone)
mork_bool CutRowCells (morkEnv *ev, morkRow *ioRow, mork_size inNewSize, morkZone *ioZone)
void ZapAtom (morkEnv *ev, morkAtom *ioAtom, morkZone *ioZone)
morkOidAtomNewRowOidAtom (morkEnv *ev, const mdbOid &inOid, morkZone *ioZone)
morkOidAtomNewTableOidAtom (morkEnv *ev, const mdbOid &inOid, morkZone *ioZone)
morkAtomNewAnonAtom (morkEnv *ev, const morkBuf &inBuf, mork_cscode inForm, morkZone *ioZone)
morkBookAtomNewBookAtom (morkEnv *ev, const morkBuf &inBuf, mork_cscode inForm, morkAtomSpace *ioSpace, mork_aid inAid, morkZone *ioZone)
morkBookAtomNewBookAtomCopy (morkEnv *ev, const morkBigBookAtom &inAtom, morkZone *ioZone)
morkBookAtomNewFarBookAtomCopy (morkEnv *ev, const morkFarBookAtom &inAtom, morkZone *ioZone)
void SetFrozen ()
void SetMutable ()
void SetAsleep ()
mork_bool IsFrozen () const
mork_bool IsMutable () const
mork_bool IsAsleep () const
void SetNodeClean ()
void SetNodeDirty ()
mork_bool IsNodeClean () const
mork_bool IsNodeDirty () const
void ZapOld (morkEnv *ev, nsIMdbHeap *ioHeap)
void CloseNode (morkEnv *ev)
mdb_err CloseMdbObject (morkEnv *ev)
NS_IMETHOD CloseMdbObject (nsIMdbEnv *ev)
mork_bool IsNode () const
void RefsUnderUsesWarning (morkEnv *ev) const
void NonNodeError (morkEnv *ev) const
void NilHeapError (morkEnv *ev) const
void NonOpenNodeError (morkEnv *ev) const
void NonMutableNodeError (morkEnv *ev) const
void RefsOverflowWarning (morkEnv *ev) const
void UsesOverflowWarning (morkEnv *ev) const
void RefsUnderflowWarning (morkEnv *ev) const
void UsesUnderflowWarning (morkEnv *ev) const
mork_bool GoodRefs () const
mork_bool BadRefs () const
mork_uses StrongRefsOnly () const
mork_refs WeakRefsOnly () const
virtual mork_refs AddStrongRef (morkEnv *ev)
virtual mork_refs CutStrongRef (morkEnv *ev)
mork_refs AddWeakRef (morkEnv *ev)
mork_refs CutWeakRef (morkEnv *ev)
const char * GetNodeAccessAsString () const
const char * GetNodeUsageAsString () const
mork_usage NodeUsage () const
mork_bool IsHeapNode () const
mork_bool IsOpenNode () const
mork_bool IsShutNode () const
mork_bool IsDeadNode () const
mork_bool IsClosingNode () const
mork_bool IsOpenOrClosingNode () const
mork_bool HasNodeAccess () const
void MarkShut ()
void MarkClosing ()
void MarkDead ()

Static Public Member Functions

static void SlotWeakPool (morkPool *me, morkEnv *ev, morkPool **ioSlot)
static void SlotStrongPool (morkPool *me, morkEnv *ev, morkPool **ioSlot)
static voidMakeNew (size_t inSize, nsIMdbHeap &ioHeap, morkEnv *ev)
static void SlotWeakNode (morkNode *me, morkEnv *ev, morkNode **ioSlot)
static void SlotStrongNode (morkNode *me, morkEnv *ev, morkNode **ioSlot)

Public Attributes

nsIMdbHeapmPool_Heap
morkDeque mPool_Blocks
morkDeque mPool_UsedHandleFrames
morkDeque mPool_FreeHandleFrames
mork_count mPool_UsedFramesCount
mork_count mPool_FreeFramesCount
nsIMdbHeapmNode_Heap
mork_base mNode_Base
mork_derived mNode_Derived
mork_access mNode_Access
mork_usage mNode_Usage
mork_able mNode_Mutable
mork_load mNode_Load
mork_uses mNode_Uses
mork_refs mNode_Refs

Private Member Functions

 morkPool (const morkPool &other)
morkPooloperator= (const morkPool &other)

Friends

class morkHandleFrame

Detailed Description

Definition at line 67 of file morkPool.h.


Constructor & Destructor Documentation

morkPool::~morkPool ( ) [virtual]

Definition at line 103 of file morkPool.cpp.

{
  MORK_ASSERT(this->IsShutNode());
}

Here is the call graph for this function:

morkPool::morkPool ( const morkUsage inUsage,
nsIMdbHeap ioHeap,
nsIMdbHeap ioSlotHeap 
)

Definition at line 109 of file morkPool.cpp.

: morkNode(inUsage, ioHeap)
, mPool_Heap( ioSlotHeap )
, mPool_UsedFramesCount( 0 )
, mPool_FreeFramesCount( 0 )
{
  // mPool_Heap is NOT refcounted
  MORK_ASSERT(ioSlotHeap);
  if ( ioSlotHeap )
    mNode_Derived = morkDerived_kPool;
}
morkPool::morkPool ( morkEnv ev,
const morkUsage inUsage,
nsIMdbHeap ioHeap,
nsIMdbHeap ioSlotHeap 
)

Definition at line 123 of file morkPool.cpp.

: morkNode(ev, inUsage, ioHeap)
, mPool_Heap( ioSlotHeap )
, mPool_UsedFramesCount( 0 )
, mPool_FreeFramesCount( 0 )
{
  if ( ioSlotHeap )
  {
    // mPool_Heap is NOT refcounted:
    // nsIMdbHeap_SlotStrongHeap(ioSlotHeap, ev, &mPool_Heap);
    if ( ev->Good() )
      mNode_Derived = morkDerived_kPool;
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

morkPool::morkPool ( const morkPool other) [private]

Member Function Documentation

mork_bool morkPool::AddRowCells ( morkEnv ev,
morkRow ioRow,
mork_size  inNewSize,
morkZone ioZone 
)

Definition at line 308 of file morkPool.cpp.

{
  // note strong implementation similarity to morkArray::Grow()

  MORK_USED_1(ioZone);
#ifdef morkZone_CONFIG_ARENA
#else /*morkZone_CONFIG_ARENA*/
#endif /*morkZone_CONFIG_ARENA*/

  mork_fill fill = ioRow->mRow_Length;
  if ( ev->Good() && fill < inNewSize ) // need more cells?
  {
    morkCell* newCells = this->NewCells(ev, inNewSize, ioZone);
    if ( newCells )
    {
      morkCell* c = newCells; // for iterating during copy
      morkCell* oldCells = ioRow->mRow_Cells;
      morkCell* end = oldCells + fill; // copy all the old cells
      while ( oldCells < end )
      {
        *c++ = *oldCells++; // bitwise copy each old cell struct
      }
      oldCells = ioRow->mRow_Cells;
      ioRow->mRow_Cells = newCells;
      ioRow->mRow_Length = (mork_u2) inNewSize;
      ++ioRow->mRow_Seed;
      
      if ( oldCells )
        this->ZapCells(ev, oldCells, fill, ioZone);
    }
  }
  return ( ev->Good() && ioRow->mRow_Length >= inNewSize );
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_uses morkNode::AddStrongRef ( morkEnv ev) [virtual, inherited]

Reimplemented in morkTable.

Definition at line 510 of file morkNode.cpp.

{
  mork_uses outUses = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_uses uses = mNode_Uses;
      mork_refs refs = mNode_Refs;
      if ( refs < uses ) // need to fix broken refs/uses relation?
      { 
        this->RefsUnderUsesWarning(ev);
        mNode_Refs = mNode_Uses = refs = uses;
      }
      if ( refs < morkNode_kMaxRefCount ) // not too great?
      {
        mNode_Refs = ++refs;
        mNode_Uses = ++uses;
      }
      else
        this->RefsOverflowWarning(ev);

      outUses = uses;
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outUses;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_refs morkNode::AddWeakRef ( morkEnv ev) [inherited]

Definition at line 599 of file morkNode.cpp.

{
  mork_refs outRefs = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_refs refs = mNode_Refs;
      if ( refs < morkNode_kMaxRefCount ) // not too great?
        mNode_Refs = ++refs;
      else
        this->RefsOverflowWarning(ev);
        
      outRefs = refs;
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outRefs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkNode::BadRefs ( ) const [inline, inherited]

Definition at line 217 of file morkNode.h.

{ return mNode_Refs < mNode_Uses; }
mdb_err morkNode::CloseMdbObject ( morkEnv ev) [inherited]

Definition at line 243 of file morkNode.cpp.

{
  // if only one ref, Handle_CutStrongRef will clean up better.
  if (mNode_Uses == 1)
    return CutStrongRef(ev);

  mdb_err outErr = 0;
  
  if ( IsNode() && IsOpenNode() )
  {
    if ( ev )
    {
      CloseMorkNode(ev);
      outErr = ev->AsErr();
    }
  }
  return outErr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in orkinFactory, orkinPortTableCursor, orkinRowCellCursor, orkinRow, orkinTableRowCursor, orkinThumb, morkStore, orkinCell, orkinEnv, orkinFile, orkinSorting, orkinStore, orkinTable, morkObject, and morkCursor.

Definition at line 238 of file morkNode.cpp.

{
  return morkNode::CloseMdbObject((morkEnv *) mev);
}

Here is the call graph for this function:

void morkPool::CloseMorkNode ( morkEnv ev) [virtual]

Reimplemented from morkNode.

Definition at line 92 of file morkPool.cpp.

{
  if ( this->IsOpenNode() )
  {
    this->MarkClosing();
    this->ClosePool(ev);
    this->MarkShut();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::CloseNode ( morkEnv ev) [inherited]

Definition at line 384 of file morkNode.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
      this->MarkShut();
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 142 of file morkPool.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
#ifdef morkZone_CONFIG_ARENA
#else /*morkZone_CONFIG_ARENA*/
    //MORK_USED_1(ioZone);
#endif /*morkZone_CONFIG_ARENA*/

      nsIMdbHeap* heap = mPool_Heap;
      nsIMdbEnv* mev = ev->AsMdbEnv();
      morkLink* aLink;
      morkDeque* d = &mPool_FreeHandleFrames;
      while ( (aLink = d->RemoveFirst()) != 0 )
        heap->Free(mev, aLink);
  
      // if the pool's closed, get rid of the frames in use too.
      d = &mPool_UsedHandleFrames;
      while ( (aLink = d->RemoveFirst()) != 0 )
        heap->Free(mev, aLink);
  
      this->MarkShut();
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkPool::CutRowCells ( morkEnv ev,
morkRow ioRow,
mork_size  inNewSize,
morkZone ioZone 
)

Definition at line 344 of file morkPool.cpp.

{
  MORK_USED_1(ioZone);
#ifdef morkZone_CONFIG_ARENA
#else /*morkZone_CONFIG_ARENA*/
#endif /*morkZone_CONFIG_ARENA*/

  mork_fill fill = ioRow->mRow_Length;
  if ( ev->Good() && fill > inNewSize ) // need fewer cells?
  {
    if ( inNewSize ) // want any row cells at all?
    {
      morkCell* newCells = this->NewCells(ev, inNewSize, ioZone);
      if ( newCells )
      {
        morkCell* saveNewCells = newCells; // Keep newcell pos
        morkCell* oldCells = ioRow->mRow_Cells;
        morkCell* oldEnd = oldCells + fill; // one past all old cells
        morkCell* newEnd = oldCells + inNewSize; // copy only kept old cells
        while ( oldCells < newEnd )
        {
          *newCells++ = *oldCells++; // bitwise copy each old cell struct
        }
        while ( oldCells < oldEnd )
        {
          if ( oldCells->mCell_Atom ) // need to unref old cell atom?
            oldCells->SetAtom(ev, (morkAtom*) 0, this); // unref cell atom
          ++oldCells;
        }
        oldCells = ioRow->mRow_Cells;
        ioRow->mRow_Cells = saveNewCells;
        ioRow->mRow_Length = (mork_u2) inNewSize;
        ++ioRow->mRow_Seed;
        
        if ( oldCells )
          this->ZapCells(ev, oldCells, fill, ioZone);
      }
    }
    else // get rid of all row cells
    {
      morkCell* oldCells = ioRow->mRow_Cells;
      ioRow->mRow_Cells = 0;
      ioRow->mRow_Length = 0;
      ++ioRow->mRow_Seed;
      
      if ( oldCells )
        this->ZapCells(ev, oldCells, fill, ioZone);
    }
  }
  return ( ev->Good() && ioRow->mRow_Length <= inNewSize );
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_uses morkNode::CutStrongRef ( morkEnv ev) [virtual, inherited]

Reimplemented in morkTable.

Definition at line 580 of file morkNode.cpp.

{
  mork_refs outRefs = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      if ( this->cut_use_count(ev) )
        outRefs = this->CutWeakRef(ev);
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outRefs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_refs morkNode::CutWeakRef ( morkEnv ev) [inherited]

Definition at line 623 of file morkNode.cpp.

{
  mork_refs outRefs = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_uses uses = mNode_Uses;
      mork_refs refs = mNode_Refs;
      if ( refs ) // not yet zero?
        mNode_Refs = --refs;
      else
        this->RefsUnderflowWarning(ev);

      if ( refs < uses ) // need to fix broken refs/uses relation?
      { 
        this->RefsUnderUsesWarning(ev);
        mNode_Refs = mNode_Uses = refs = uses;
      }
        
      outRefs = refs;
      if ( !refs ) // last reference gone? time to destroy node?
        this->ZapOld(ev, mNode_Heap); // self destroy, use this no longer
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outRefs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char * morkNode::GetNodeAccessAsString ( ) const [inherited]

Definition at line 658 of file morkNode.cpp.

{
  const char* outString = morkNode_kBroken;
  switch( mNode_Access )
  {
    case morkAccess_kOpen: outString = "open"; break;
    case morkAccess_kClosing: outString = "closing"; break;
    case morkAccess_kShut: outString = "shut"; break;
    case morkAccess_kDead: outString = "dead"; break;
  }
  return outString;
}
const char * morkNode::GetNodeUsageAsString ( ) const [inherited]

Definition at line 672 of file morkNode.cpp.

{
  const char* outString = morkNode_kBroken;
  switch( mNode_Usage )
  {
    case morkUsage_kHeap: outString = "heap"; break;
    case morkUsage_kStack: outString = "stack"; break;
    case morkUsage_kMember: outString = "member"; break;
    case morkUsage_kGlobal: outString = "global"; break;
    case morkUsage_kPool: outString = "pool"; break;
    case morkUsage_kNone: outString = "none"; break;
  }
  return outString;
}
mork_bool morkNode::GoodRefs ( ) const [inline, inherited]

Definition at line 216 of file morkNode.h.

{ return mNode_Refs >= mNode_Uses; }
mork_bool morkNode::HasNodeAccess ( ) const [inline, inherited]

Definition at line 251 of file morkNode.h.

  { return ( IsOpenNode() || IsShutNode() || IsClosingNode() ); }

Here is the call graph for this function:

mork_bool morkNode::IsAsleep ( ) const [inline, inherited]

Definition at line 142 of file morkNode.h.

mork_bool morkNode::IsClosingNode ( ) const [inline, inherited]

Definition at line 245 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkNode::IsDeadNode ( ) const [inline, inherited]

Definition at line 242 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkNode::IsFrozen ( ) const [inline, inherited]

Definition at line 140 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkNode::IsHeapNode ( ) const [inline, inherited]

Definition at line 233 of file morkNode.h.

  { return mNode_Usage == morkUsage_kHeap; }
mork_bool morkNode::IsMutable ( ) const [inline, inherited]

Definition at line 141 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkNode::IsNode ( ) const [inline, inherited]

Definition at line 193 of file morkNode.h.

  { return mNode_Base == morkBase_kNode; }
mork_bool morkNode::IsNodeClean ( ) const [inline, inherited]

Definition at line 147 of file morkNode.h.

{ return mNode_Load == morkLoad_kClean; }

Here is the caller graph for this function:

mork_bool morkNode::IsNodeDirty ( ) const [inline, inherited]

Definition at line 148 of file morkNode.h.

{ return mNode_Load == morkLoad_kDirty; }

Here is the caller graph for this function:

mork_bool morkNode::IsOpenNode ( ) const [inline, inherited]

Definition at line 236 of file morkNode.h.

mork_bool morkNode::IsOpenOrClosingNode ( ) const [inline, inherited]

Definition at line 248 of file morkNode.h.

  { return IsOpenNode() || IsClosingNode(); }

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkPool::IsPool ( ) const [inline]

Definition at line 112 of file morkPool.h.

  { return IsNode() && mNode_Derived == morkDerived_kPool; }

Here is the call graph for this function:

mork_bool morkNode::IsShutNode ( ) const [inline, inherited]

Definition at line 239 of file morkNode.h.

Here is the caller graph for this function:

void * morkNode::MakeNew ( size_t  inSize,
nsIMdbHeap ioHeap,
morkEnv ev 
) [static, inherited]

Definition at line 177 of file morkNode.cpp.

{
  void* node = 0;
  if ( &ioHeap )
  {
    ioHeap.Alloc(ev->AsMdbEnv(), inSize, (void **) &node);
    if ( !node )
      ev->OutOfMemoryError();
  }
  else
    ev->NilPointerError();
  
  return node;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::MarkClosing ( ) [inline, inherited]

Definition at line 255 of file morkNode.h.

void morkNode::MarkDead ( ) [inline, inherited]

Definition at line 256 of file morkNode.h.

void morkNode::MarkShut ( ) [inline, inherited]

Definition at line 254 of file morkNode.h.

morkAtom * morkPool::NewAnonAtom ( morkEnv ev,
const morkBuf inBuf,
mork_cscode  inForm,
morkZone ioZone 
)

Definition at line 451 of file morkPool.cpp.

{
  morkAtom* newAtom = 0;

  mork_bool needBig = ( inForm || inBuf.mBuf_Fill > 255 );
  mork_size size = ( needBig )?
    morkBigAnonAtom::SizeForFill(inBuf.mBuf_Fill) :
    morkWeeAnonAtom::SizeForFill(inBuf.mBuf_Fill);

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkAtom*) ioZone->ZoneNewChip(ev, size);
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**) &newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if ( newAtom )
  {
    if ( needBig )
      ((morkBigAnonAtom*) newAtom)->InitBigAnonAtom(ev, inBuf, inForm);
    else
      ((morkWeeAnonAtom*) newAtom)->InitWeeAnonAtom(ev, inBuf);
  }
  return newAtom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

morkBookAtom * morkPool::NewBookAtom ( morkEnv ev,
const morkBuf inBuf,
mork_cscode  inForm,
morkAtomSpace ioSpace,
mork_aid  inAid,
morkZone ioZone 
)

Definition at line 482 of file morkPool.cpp.

{
  morkBookAtom* newAtom = 0;

  mork_bool needBig = ( inForm || inBuf.mBuf_Fill > 255 );
  mork_size size = ( needBig )?
    morkBigBookAtom::SizeForFill(inBuf.mBuf_Fill) :
    morkWeeBookAtom::SizeForFill(inBuf.mBuf_Fill);

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkBookAtom*) ioZone->ZoneNewChip(ev, size);
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**) &newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if ( newAtom )
  {
    if ( needBig )
      ((morkBigBookAtom*) newAtom)->InitBigBookAtom(ev,
        inBuf, inForm, ioSpace, inAid);
    else
      ((morkWeeBookAtom*) newAtom)->InitWeeBookAtom(ev,
        inBuf, ioSpace, inAid);
  }
  return newAtom;
}

Here is the call graph for this function:

Definition at line 515 of file morkPool.cpp.

{
  morkBookAtom* newAtom = 0;

  mork_cscode form = inAtom.mBigBookAtom_Form;
  mork_fill fill = inAtom.mBigBookAtom_Size;
  mork_bool needBig = ( form || fill > 255 );
  mork_size size = ( needBig )?
    morkBigBookAtom::SizeForFill(fill) :
    morkWeeBookAtom::SizeForFill(fill);

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkBookAtom*) ioZone->ZoneNewChip(ev, size);
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**) &newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if ( newAtom )
  {
    morkBuf buf(inAtom.mBigBookAtom_Body, fill);
    if ( needBig )
      ((morkBigBookAtom*) newAtom)->InitBigBookAtom(ev,
        buf, form, inAtom.mBookAtom_Space, inAtom.mBookAtom_Id);
    else
      ((morkWeeBookAtom*) newAtom)->InitWeeBookAtom(ev,
        buf, inAtom.mBookAtom_Space, inAtom.mBookAtom_Id);
  }
  return newAtom;
}

Here is the call graph for this function:

morkCell * morkPool::NewCells ( morkEnv ev,
mork_size  inSize,
morkZone ioZone 
)

Definition at line 265 of file morkPool.cpp.

{
  morkCell* newCells = 0;

  mork_size size = inSize * sizeof(morkCell);
  if ( size )
  {
#ifdef morkZone_CONFIG_ARENA
    // a zone 'run' knows its size, and can indeed be deallocated:
    newCells = (morkCell*) ioZone->ZoneNewRun(ev, size);
#else /*morkZone_CONFIG_ARENA*/
    MORK_USED_1(ioZone);
    mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**) &newCells);
#endif /*morkZone_CONFIG_ARENA*/
  }
    
  // note morkAtom depends on having nil stored in all new mCell_Atom slots:
  if ( newCells )
    MORK_MEMSET(newCells, 0, size);
  return newCells;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 551 of file morkPool.cpp.

{
  morkBookAtom* newAtom = 0;

  mork_cscode form = inAtom.mFarBookAtom_Form;
  mork_fill fill = inAtom.mFarBookAtom_Size;
  mork_bool needBig = ( form || fill > 255 );
  mork_size size = ( needBig )?
    morkBigBookAtom::SizeForFill(fill) :
    morkWeeBookAtom::SizeForFill(fill);

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkBookAtom*) ioZone->ZoneNewChip(ev, size);
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**) &newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if ( newAtom )
  {
    morkBuf buf(inAtom.mFarBookAtom_Body, fill);
    if ( needBig )
      ((morkBigBookAtom*) newAtom)->InitBigBookAtom(ev,
        buf, form, inAtom.mBookAtom_Space, inAtom.mBookAtom_Id);
    else
      ((morkWeeBookAtom*) newAtom)->InitWeeBookAtom(ev,
        buf, inAtom.mBookAtom_Space, inAtom.mBookAtom_Id);
  }
  return newAtom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

morkHandleFace * morkPool::NewHandle ( morkEnv ev,
mork_size  inSize,
morkZone ioZone 
)

Definition at line 180 of file morkPool.cpp.

{
  void* newBlock = 0;
  if ( inSize <= sizeof(morkHandleFrame) )
  {
    morkLink* firstLink = mPool_FreeHandleFrames.RemoveFirst();
    if ( firstLink )
    {
      newBlock = firstLink;
      if ( mPool_FreeFramesCount )
        --mPool_FreeFramesCount;
      else
        ev->NewWarning("mPool_FreeFramesCount underflow");
    }
    else
      mPool_Heap->Alloc(ev->AsMdbEnv(), sizeof(morkHandleFrame),
        (void**) &newBlock);
  }
  else
  {
    ev->NewWarning("inSize > sizeof(morkHandleFrame)");
    mPool_Heap->Alloc(ev->AsMdbEnv(), inSize, (void**) &newBlock);
  }
#ifdef morkZone_CONFIG_ARENA
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
#endif /*morkZone_CONFIG_ARENA*/

  return (morkHandleFace*) newBlock;
}

Here is the call graph for this function:

Here is the caller graph for this function:

morkRow * morkPool::NewRow ( morkEnv ev,
morkZone ioZone 
)

Definition at line 231 of file morkPool.cpp.

{
  morkRow* newRow = 0;
  
#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newRow = (morkRow*) ioZone->ZoneNewChip(ev, sizeof(morkRow));
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), sizeof(morkRow), (void**) &newRow);
#endif /*morkZone_CONFIG_ARENA*/

  if ( newRow )
    MORK_MEMSET(newRow, 0, sizeof(morkRow));
  
  return newRow;
}

Here is the call graph for this function:

Here is the caller graph for this function:

morkOidAtom * morkPool::NewRowOidAtom ( morkEnv ev,
const mdbOid inOid,
morkZone ioZone 
)

Definition at line 414 of file morkPool.cpp.

{
  morkOidAtom* newAtom = 0;
  
#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkOidAtom*) ioZone->ZoneNewChip(ev, sizeof(morkOidAtom));
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), sizeof(morkOidAtom),(void**) &newAtom);
#endif /*morkZone_CONFIG_ARENA*/

  if ( newAtom )
    newAtom->InitRowOidAtom(ev, inOid);
  return newAtom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

morkOidAtom * morkPool::NewTableOidAtom ( morkEnv ev,
const mdbOid inOid,
morkZone ioZone 
)

Definition at line 433 of file morkPool.cpp.

{
  morkOidAtom* newAtom = 0;

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkOidAtom*) ioZone->ZoneNewChip(ev, sizeof(morkOidAtom));
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), sizeof(morkOidAtom), (void**) &newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if ( newAtom )
    newAtom->InitTableOidAtom(ev, inOid);
  return newAtom;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::NilHeapError ( morkEnv ev) const [inherited]

Definition at line 354 of file morkNode.cpp.

{
  ev->NewError("nil mNode_Heap");
}

Here is the caller graph for this function:

mork_usage morkNode::NodeUsage ( ) const [inline, inherited]

Definition at line 231 of file morkNode.h.

{ return mNode_Usage; }
void morkNode::NonMutableNodeError ( morkEnv ev) const [inherited]

Definition at line 348 of file morkNode.cpp.

{
  ev->NewError("non-mutable-morkNode");
}

Here is the caller graph for this function:

void morkNode::NonNodeError ( morkEnv ev) const [inherited]

Definition at line 336 of file morkNode.cpp.

{
  ev->NewError("non-morkNode");
}
void morkNode::NonOpenNodeError ( morkEnv ev) const [inherited]

Definition at line 342 of file morkNode.cpp.

{
  ev->NewError("non-open-morkNode");
}

Here is the caller graph for this function:

void* morkPool::operator new ( size_t  inSize,
nsIMdbHeap ioHeap,
morkEnv ev 
) [inline]

Reimplemented from morkNode.

Definition at line 120 of file morkPool.h.

  { return morkNode::MakeNew(inSize, ioHeap, ev); }

Here is the call graph for this function:

Here is the caller graph for this function:

void* morkPool::operator new ( size_t  inSize) [inline]

Definition at line 123 of file morkPool.h.

  { return ::operator new(inSize); }

Here is the call graph for this function:

morkPool& morkPool::operator= ( const morkPool other) [private]
void morkNode::RefsOverflowWarning ( morkEnv ev) const [inherited]

Definition at line 360 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Refs overflow");
}

Here is the caller graph for this function:

void morkNode::RefsUnderflowWarning ( morkEnv ev) const [inherited]

Definition at line 372 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Refs underflow");
}

Here is the caller graph for this function:

void morkNode::RefsUnderUsesWarning ( morkEnv ev) const [inherited]

Definition at line 330 of file morkNode.cpp.

{
  ev->NewError("mNode_Refs < mNode_Uses");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::SetAsleep ( ) [inline, inherited]

Definition at line 138 of file morkNode.h.

void morkNode::SetFrozen ( ) [inline, inherited]

Definition at line 136 of file morkNode.h.

void morkNode::SetMutable ( ) [inline, inherited]

Definition at line 137 of file morkNode.h.

void morkNode::SetNodeClean ( ) [inline, inherited]

Definition at line 144 of file morkNode.h.

Here is the caller graph for this function:

void morkNode::SetNodeDirty ( ) [inline, inherited]

Definition at line 145 of file morkNode.h.

Here is the caller graph for this function:

void morkNode::SlotStrongNode ( morkNode me,
morkEnv ev,
morkNode **  ioSlot 
) [static, inherited]

Definition at line 466 of file morkNode.cpp.

{
  morkNode* node = *ioSlot;
  if ( me != node )
  {
    if ( node )
    {
      // what if this nulls out the ev and causes asserts?
      // can we move this after the CutStrongRef()?
      *ioSlot = 0;
      node->CutStrongRef(ev);
    }
    if ( me && me->AddStrongRef(ev) )
      *ioSlot = me;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkPool::SlotStrongPool ( morkPool me,
morkEnv ev,
morkPool **  ioSlot 
) [inline, static]

Definition at line 176 of file morkPool.h.

  { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::SlotWeakNode ( morkNode me,
morkEnv ev,
morkNode **  ioSlot 
) [static, inherited]

Definition at line 489 of file morkNode.cpp.

{
  morkNode* node = *ioSlot;
  if ( me != node )
  {
    if ( node )
    {
      *ioSlot = 0;
      node->CutWeakRef(ev);
    }
    if ( me && me->AddWeakRef(ev) )
      *ioSlot = me;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkPool::SlotWeakPool ( morkPool me,
morkEnv ev,
morkPool **  ioSlot 
) [inline, static]

Definition at line 172 of file morkPool.h.

  { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

mork_uses morkNode::StrongRefsOnly ( ) const [inline, inherited]

Definition at line 219 of file morkNode.h.

{ return mNode_Uses; }

Here is the caller graph for this function:

void morkNode::UsesOverflowWarning ( morkEnv ev) const [inherited]

Definition at line 366 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Uses overflow");
}
void morkNode::UsesUnderflowWarning ( morkEnv ev) const [inherited]

Definition at line 378 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Uses underflow");
}

Here is the caller graph for this function:

mork_refs morkNode::WeakRefsOnly ( ) const [inline, inherited]

Definition at line 220 of file morkNode.h.

{ return (mork_refs) ( mNode_Refs - mNode_Uses ); }

Here is the caller graph for this function:

void morkPool::ZapAtom ( morkEnv ev,
morkAtom ioAtom,
morkZone ioZone 
)

Definition at line 400 of file morkPool.cpp.

{
#ifdef morkZone_CONFIG_ARENA
  if ( !ioAtom )
    ev->NilPointerWarning(); // a zone 'chip' cannot be freed
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  if ( ioAtom )
    mPool_Heap->Free(ev->AsMdbEnv(), ioAtom);
#endif /*morkZone_CONFIG_ARENA*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkPool::ZapCells ( morkEnv ev,
morkCell ioVector,
mork_size  inSize,
morkZone ioZone 
)

Definition at line 289 of file morkPool.cpp.

{
  MORK_USED_1(inSize);

  if ( ioVector )
  {
#ifdef morkZone_CONFIG_ARENA
    // a zone 'run' knows its size, and can indeed be deallocated:
    ioZone->ZoneZapRun(ev, ioVector);
#else /*morkZone_CONFIG_ARENA*/
    MORK_USED_1(ioZone);
    mPool_Heap->Free(ev->AsMdbEnv(), ioVector);
#endif /*morkZone_CONFIG_ARENA*/
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkPool::ZapHandle ( morkEnv ev,
morkHandleFace *  ioHandle 
)

Definition at line 212 of file morkPool.cpp.

{
  if ( ioHandle )
  {
    morkLink* handleLink = (morkLink*) ioHandle;
    mPool_FreeHandleFrames.AddLast(handleLink);
    ++mPool_FreeFramesCount;
    // lets free all handles to track down leaks 
    // - uncomment out next 3 lines, comment out above 2
//      nsIMdbHeap* heap = mPool_Heap;
//      nsIMdbEnv* mev = ev->AsMdbEnv();
//      heap->Free(mev, handleLink);
 
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::ZapOld ( morkEnv ev,
nsIMdbHeap ioHeap 
) [inherited]

Definition at line 193 of file morkNode.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_usage usage = mNode_Usage; // mNode_Usage before ~morkNode
      this->morkNode::~morkNode(); // first call polymorphic destructor
      if ( ioHeap ) // was this node heap allocated?
        ioHeap->Free(ev->AsMdbEnv(), this);
      else if ( usage == morkUsage_kPool ) // mNode_Usage before ~morkNode
      {
        morkHandle* h = (morkHandle*) this;
        if ( h->IsHandle() && h->GoodHandleTag() )
        {
          if ( h->mHandle_Face )
          {
            if (ev->mEnv_HandlePool)
              ev->mEnv_HandlePool->ZapHandle(ev, h->mHandle_Face);
            else if (h->mHandle_Env && h->mHandle_Env->mEnv_HandlePool)
              h->mHandle_Env->mEnv_HandlePool->ZapHandle(ev, h->mHandle_Face);
          }
          else
            ev->NilPointerError();
        }
      }
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkPool::ZapRow ( morkEnv ev,
morkRow ioRow,
morkZone ioZone 
)

Definition at line 250 of file morkPool.cpp.

{
#ifdef morkZone_CONFIG_ARENA
  if ( !ioRow )
    ev->NilPointerWarning(); // a zone 'chip' cannot be freed
#else /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  if ( ioRow )
    mPool_Heap->Free(ev->AsMdbEnv(), ioRow);
#endif /*morkZone_CONFIG_ARENA*/
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class morkHandleFrame [friend, inherited]

Reimplemented in morkHandle.

Definition at line 131 of file morkNode.h.


Member Data Documentation

Definition at line 122 of file morkNode.h.

Definition at line 119 of file morkNode.h.

Definition at line 120 of file morkNode.h.

Definition at line 117 of file morkNode.h.

Definition at line 125 of file morkNode.h.

Definition at line 124 of file morkNode.h.

Definition at line 128 of file morkNode.h.

Definition at line 123 of file morkNode.h.

Definition at line 127 of file morkNode.h.

Definition at line 86 of file morkPool.h.

Definition at line 93 of file morkPool.h.

Definition at line 90 of file morkPool.h.

Definition at line 84 of file morkPool.h.

Definition at line 92 of file morkPool.h.

Definition at line 89 of file morkPool.h.


The documentation for this class was generated from the following files: