YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftwareFoundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/** Executeanallocatedtodirtytransition. Thistransitionshouldbeexecutedbythewriterthatownstherecord, beforetherecordismodified.
*/ void allocated_to_dirty(pfs_dirty_state *copy_ptr)
{
uint32 copy= copy_version_state(); /* Make sure the record was ALLOCATED. */
assert((copy & STATE_MASK) == PFS_LOCK_ALLOCATED); /* Keep the same version, set the DIRTY state */
uint32 new_val= (copy & VERSION_MASK) + PFS_LOCK_DIRTY; /* We own the record, no need to use compare and swap. */
m_version_state.store(new_val);
copy_ptr->m_version_state= new_val;
}
/** Executeadirtytoallocatedtransition. Thistransitionshouldbeexecutedbythewriterthatownstherecord, aftertherecordisinastatereadytoberead.
*/ void dirty_to_allocated(const pfs_dirty_state *copy)
{ /* Make sure the record was DIRTY. */
assert((copy->m_version_state & STATE_MASK) == PFS_LOCK_DIRTY); /* Increment the version, set the ALLOCATED state */
uint32 new_val= (copy->m_version_state & VERSION_MASK) + VERSION_INC + PFS_LOCK_ALLOCATED;
m_version_state.store(new_val);
}
/** Initializealocktoallocated. Thistransitionshouldbeexecutedbythewriterthatownstherecordandthelock, aftertherecordisinastatereadytoberead.
*/ void set_allocated(void)
{ /* Do not set the version to 0, read the previous value. */
uint32 copy= copy_version_state(); /* Increment the version, set the ALLOCATED state */
uint32 new_val= (copy & VERSION_MASK) + VERSION_INC + PFS_LOCK_ALLOCATED;
m_version_state.store(new_val);
}
/** Initializealocktodirty.
*/ void set_dirty(pfs_dirty_state *copy_ptr)
{ /* Do not set the version to 0, read the previous value. */
uint32 copy= m_version_state.load(); /* Increment the version, set the DIRTY state */
uint32 new_val= (copy & VERSION_MASK) + VERSION_INC + PFS_LOCK_DIRTY;
m_version_state.store(new_val);
copy_ptr->m_version_state= new_val;
}
/** Executeadirtytofreetransition. Thistransitionshouldbeexecutedbythewriterthatownstherecord.
*/ void dirty_to_free(const pfs_dirty_state *copy)
{ /* Make sure the record was DIRTY. */
assert((copy->m_version_state & STATE_MASK) == PFS_LOCK_DIRTY); /* Keep the same version, set the FREE state */
uint32 new_val= (copy->m_version_state & VERSION_MASK) + PFS_LOCK_FREE;
m_version_state.store(new_val);
}
/** Executeanallocatedtofreetransition. Thistransitionshouldbeexecutedbythewriterthatownstherecord.
*/ void allocated_to_free(void)
{ /* IfthisrecordisnotintheALLOCATEDstateandthecalleristrying tofreeit,thisisabug:thecallerisconfused, andpotentiallydamagingdataownedbyanotherthreadorobject.
*/
uint32 copy= copy_version_state(); /* Make sure the record was ALLOCATED. */
assert(((copy & STATE_MASK) == PFS_LOCK_ALLOCATED)); /* Keep the same version, set the FREE state */
uint32 new_val= (copy & VERSION_MASK) + PFS_LOCK_FREE;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.