Reference counting atom with delete locking
This module contains code for adding reference counting and delete locking to object by 'deriving' then from a base MX_ATOM object. (../include/deds/atom.h)
Part of the deds library.
MX_ATOM
Base class for reference counting and delete locking
MX_ATOM is an object intended to be used as a base class to implement reference counting and delete locking in the derived class.
Properly constructed MX_ATOM objects are bit-copy-correct which means that a binary copy retains proper functioning. The copied object should not be used after the binary copy.
Because MX_ATOM is bit-copy-correct it can safely be placed in a MX_VECTOR or the memory realloc'd. (../include/deds/atom.h)
# define MXATOM(v)
Convert to MX_ATOM
This macro return the base MX_ATOM for an object derived from MX_ATOM. (../include/deds/atom.h)
# define mx_atom(a,d,s)
Construct an MX_ATOM
This macro constructs a MX_ATOM which is a base object for reference counting. (../include/deds/atom.h)
# define mx_delete(a)
Destroy an MX_ATOM
This macro causes an object to be marked for destruction. If no locks (MX_LOCK) or references (MX_REF) exist for this object then the object is destroyed and if appropitae the memory is released. (../include/deds/atom.h)
# define mx_locked(a)
Find out if an object is locked or not
MX_LOCK
Stop MX_ATOMs from getting deleted
This object implements a delete lock for an MX_ATOM. While a valid MX_LOCK exists for an MX_ATOM object (or one derived from it) the object is guaranteed not be deleted. An object can have multiple locks placed on it.
MX_LOCK is NOT bit-copy-correct so it cannot safely be placed in a MX_VECTOR or in memory that gets realloc'd. (../include/deds/atom.h)
# define mx_lock(l,a)
Construct a MX_LOCK
This macro creates a lock for an object derived from MX_ATOM. The locked MX_ATOM is guaranteed not to be deleted while a valid lock exists. (../include/deds/atom.h)
unsigned mx_unlock(MX_LOCK* lock)
Destruct a MX_LOCK
This function destroys a MX_LOCK and removes it from it's associated MX_ATOM object. If the object has been flagged for deletion (with the mx_delete() macro) then removal of the last lock caused the MX_ATOM destructor to be called and (if necessary) memory returned to the operating system.
If the release of the lock triggered calling of the object destructor then the function returns non-zero. If this occurs then it is not safe to access the object anymore. If this function returns false then either:
unsigned mx_lastlock(const MX_LOCK* lock)
Find out if a lock is the last one of an object
# define MX_REF(type)
A reference type, a typed MX_LOCK
This macro defines a MX_LOCK where the target is of some defined type. A reference functions the same way as a MX_LOCK except the locked (i.e. referenced) object is available in a typesafe way. A pointer to the reference target is available with the MXREF macro. (../include/deds/atom.h)
# define mx_ref(r,t)
Construct a MX_REF
The macro constructs a MX_REF to an object. (../include/deds/atom.h)
# define mx_unref(r)
Destruct a MX_REF
The macro destroys a MX_REF to an object. The object may be deleted in the dereference, see the mx_unlock() macro. (../include/deds/atom.h)
# define MXREF(r)
Return the object behind a MX_REF
Return the object behind the MX_REF to an object. (../include/deds/atom.h)
void* mx__atom(MX_ATOM* atom, MX__ATOM_DESTRUCT destruct, size_t datasize)
Construct an MX_ATOM
This internal function constructs an MX_ATOM and registers a destructor to call when the object gets deleted. (../include/deds/atom.c)
If insufficient object size is suggested then the actually allocated memory is increased to safely contain an MX_ATOM. Passing 0 for datasize is safe. (../include/deds/atom.c)
If no existing MX_ATOM memory is given then memory will be allocated. (../include/deds/atom.c)
The address of the newly constructed MX_ATOM is returned. (../include/deds/atom.c)
Generated by MXDOC 2.2 on Sun Feb 4 15:16:26 2007