libbio
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
bio::chemical::AtomicCow Class Reference

#include <AtomicCow.h>

Inheritance diagram for bio::chemical::AtomicCow:
Inheritance graph
[legend]
Collaboration diagram for bio::chemical::AtomicCow:
Collaboration graph
[legend]

Public Member Functions

 AtomicCow (Pointer< Atom > source, AtomicNumber bondId, Pointer< physical::Wave > bondedSnapshot)
 
bool IsValid () const
 
- Public Member Functions inherited from bio::CowPtr< physical::Wave >
 CowPtr ()
 
 CowPtr (physical::Wave *owned, bool immutable=false)
 
 CowPtr (const CowPtr &other)
 
bool IsBorrowed () const
 
CowPtroperator= (const CowPtr &other)
 
 ~CowPtr ()
 
const physical::WaveView () const
 
bool IsShared () const
 
bool IsNull () const
 
physical::WaveMoo (CLONE cloneFn)
 
physical::WaveMutable ()
 
void Reset (physical::Wave *owned)
 

Protected Member Functions

const physical::WaveReadBonded () const
 
Pointer< physical::WaveWriteBonded ()
 

Protected Attributes

Pointer< AtommSource
 
AtomicNumber mBondId
 

Additional Inherited Members

- Public Types inherited from bio::CowPtr< physical::Wave >
typedef physical::Wave Type
 
- Static Public Member Functions inherited from bio::CowPtr< physical::Wave >
static CowPtr Borrow (physical::Wave *borrowed)
 

Detailed Description

AtomicCow — the type-erased base of the bonded copy-on-write access handle (RFC_BONDED_COW_HANDLE §12), and a CowPtr< physical::Wave > by inheritance.

sceon's hierarchy: CowPtr -> AtomicCow -> Cow< T >. AtomicCow IS-A CowPtr whose slot holds a BORROWED snapshot of the bonded it was made from. Borrowed (not owned) is load-bearing: a borrowed slot carries NO refcount, so the handle does NOT inflate the bonded's owner-count — copy-on-write detach decisions on the source bond stay correct (they reflect only the bonds that share the bonded, never transient handles). The snapshot is captured under a shared lock when As<>() hands the handle out and is exactly as long-lived as the raw pointer the pre-COW As<>() returned.

The point is DEFERRED detach:

NOT deleted through a CowPtr* — the inherited dtor stays non-virtual (CowPtr.h).

Constructor & Destructor Documentation

◆ AtomicCow()

bio::chemical::AtomicCow::AtomicCow ( Pointer< Atom source,
AtomicNumber  bondId,
Pointer< physical::Wave bondedSnapshot 
)
inline
Parameters
sourcethe Atom the bonded came from (NULL = an empty/invalid handle).
bondIdthe id of the bonded within source (re-resolved on Write so the handle survives an mBonds reallocation between handout and use).
bondedSnapshotthe bonded resolved under source's shared lock at handout.

Member Function Documentation

◆ IsValid()

bool bio::chemical::AtomicCow::IsValid ( ) const
inline
Returns
true iff this handle is bound to a source Atom.

◆ ReadBonded()

const physical::Wave * bio::chemical::AtomicCow::ReadBonded ( ) const
inlineprotected

SHARE: the borrowed snapshot of the bonded (never detaches, never refcounts).

Returns
the shared bonded Wave (const), or NULL.

◆ WriteBonded()

Pointer< physical::Wave > bio::chemical::AtomicCow::WriteBonded ( )
inlineprotected

DETACH: copy-on-write the SOURCE bond under a fresh exclusive lock and refresh the snapshot to the now-private bonded.

Returns
the uniquely-owned (post-detach) bonded Wave, or NULL.

Member Data Documentation

◆ mBondId

AtomicNumber bio::chemical::AtomicCow::mBondId
protected

◆ mSource

Pointer< Atom > bio::chemical::AtomicCow::mSource
protected

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