reference_counting.htm 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
  2. <html><head>
  3. <title>reference_counting</title>
  4. </head><body>
  5. <p>[<a href="mxdoc.htm">mainpage</a>]
  6. [<a href="tags.htm">tags</a>]<br>
  7. <h1>tag: reference_counting</h1><ul><li>
  8. <a name="MX_ATOM"><code>MX_ATOM</code></a>
  9. <p>
  10. <p><b>Base class for reference counting and delete locking</b><p>
  11. MX_ATOM is an object intended to be used as a base class to
  12. implement reference counting and delete locking in the derived class.
  13. <p>
  14. Properly constructed MX_ATOM objects are bit-copy-correct which means that
  15. a binary copy retains proper functioning. The copied object should not be
  16. used after the binary copy.
  17. <p>
  18. Because MX_ATOM is bit-copy-correct it can safely be placed in a MX_VECTOR
  19. or the memory realloc'd.
  20. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  21. <p></li>
  22. <li>
  23. <a name=" define mx_atom(a,d,s)"><code># define mx_atom(a,d,s)</code></a>
  24. <p>
  25. <p><b>Construct an MX_ATOM</b><p>
  26. This macro constructs a MX_ATOM which is a base object for reference counting.
  27. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  28. <p></li>
  29. <li>
  30. <a name=" define mx_delete(a)"><code># define mx_delete(a)</code></a>
  31. <p>
  32. <p><b>Destroy an MX_ATOM</b><p>
  33. This macro causes an object to be marked for destruction. If no locks (MX_LOCK)
  34. or references (MX_REF) exist for this object then the object is destroyed and
  35. if appropitae the memory is released.
  36. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  37. <p></li>
  38. <li>
  39. <a name=" define mx_locked(a)"><code># define mx_locked(a)</code></a>
  40. <p>
  41. <p><b>Find out if an object is locked or not </b><p>
  42. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  43. <p></li>
  44. <li>
  45. <a name="MX_LOCK"><code>MX_LOCK</code></a>
  46. <p>
  47. <p><b>Stop MX_ATOMs from getting deleted</b><p>
  48. This object implements a delete lock for an MX_ATOM. While a valid
  49. MX_LOCK exists for an MX_ATOM object (or one derived from it) the
  50. object is guaranteed not be deleted. An object can have multiple locks
  51. placed on it. <p>
  52. MX_LOCK is NOT bit-copy-correct so it cannot safely be placed in a MX_VECTOR
  53. or in memory that gets realloc'd.
  54. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  55. <p></li>
  56. <li>
  57. <a name=" define mx_lock(l,a)"><code># define mx_lock(l,a)</code></a>
  58. <p>
  59. <p><b>Construct a MX_LOCK</b><p>
  60. This macro creates a lock for an object derived from MX_ATOM. The locked
  61. MX_ATOM is guaranteed not to be deleted while a valid lock exists.
  62. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  63. <p></li>
  64. <li>
  65. <a name="unsigned mx_unlock(MX_LOCK* lock)"><code>unsigned mx_unlock(MX_LOCK* lock)</code></a>
  66. <p>
  67. <p><b>Destruct a MX_LOCK</b><p>
  68. This function destroys a MX_LOCK and removes it from it's associated
  69. MX_ATOM object. If the object has been flagged for deletion (with the
  70. mx_delete() macro) then removal of the last lock caused the MX_ATOM
  71. destructor to be called and (if necessary) memory returned to the operating
  72. system.
  73. <p>
  74. If the release of the lock triggered calling of the object destructor then
  75. the function returns non-zero. If this occurs then it is not safe to access
  76. the object anymore. If this function returns false then either:<ol>
  77. <li>Other locks exist for the object.</li>
  78. <li>The object hasn't been deleted yet.</li>
  79. </ol>In either case you can still safely access the object after the unlock.
  80. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  81. <p></li>
  82. <li>
  83. <a name="unsigned mx_lastlock(const MX_LOCK* lock)"><code>unsigned mx_lastlock(const MX_LOCK* lock)</code></a>
  84. <p>
  85. <p><b>Find out if a lock is the last one of an object </b><p>
  86. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  87. <p></li>
  88. <li>
  89. <a name=" define MX_REF(type)"><code># define MX_REF(type)</code></a>
  90. <p>
  91. <p><b>A reference type, a typed MX_LOCK</b><p>
  92. This macro defines a MX_LOCK where the target is of some defined type.
  93. A reference functions the same way as a MX_LOCK except the locked (i.e. referenced)
  94. object is available in a typesafe way. A pointer to the reference target is
  95. available with the MXREF macro.
  96. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  97. <p></li>
  98. <li>
  99. <a name=" define mx_ref(r,t)"><code># define mx_ref(r,t)</code></a>
  100. <p>
  101. <p><b>Construct a MX_REF</b><p>
  102. The macro constructs a MX_REF to an object.
  103. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  104. <p></li>
  105. <li>
  106. <a name=" define mx_unref(r)"><code># define mx_unref(r)</code></a>
  107. <p>
  108. <p><b>Destruct a MX_REF</b><p>
  109. The macro destroys a MX_REF to an object. The object may
  110. be deleted in the dereference, see the mx_unlock() macro.
  111. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  112. <p></li>
  113. <li>
  114. <a name=" define MXREF(r)"><code># define MXREF(r)</code></a>
  115. <p>
  116. <p><b>Return the object behind a MX_REF</b><p>
  117. Return the object behind the MX_REF to an object.
  118. (<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
  119. <p></li>
  120. </ul><p>Generated by <a href="http://www.deleveld.dds.nl/mxdoc/index.htm">MXDOC</a> 2.2 on Sun Feb 4 15:16:26 2007
  121. </body></html>