summaryrefslogtreecommitdiff
path: root/dnn/Disposable.cc
diff options
context:
space:
mode:
authorchatty2000-11-28 14:52:15 +0000
committerchatty2000-11-28 14:52:15 +0000
commitbcb19dbd53973ff7efd9b2838de121d1e23430f4 (patch)
tree4aa6404ca732d1a32e11b0be1762dcb7ef9fbdb6 /dnn/Disposable.cc
parent325530e630c68c7c10a2f4339f5b43434fcd0329 (diff)
downloadivy-league-bcb19dbd53973ff7efd9b2838de121d1e23430f4.zip
ivy-league-bcb19dbd53973ff7efd9b2838de121d1e23430f4.tar.gz
ivy-league-bcb19dbd53973ff7efd9b2838de121d1e23430f4.tar.bz2
ivy-league-bcb19dbd53973ff7efd9b2838de121d1e23430f4.tar.xz
Lots of files were added around '96
Diffstat (limited to 'dnn/Disposable.cc')
-rwxr-xr-xdnn/Disposable.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/dnn/Disposable.cc b/dnn/Disposable.cc
new file mode 100755
index 0000000..4e8a03a
--- /dev/null
+++ b/dnn/Disposable.cc
@@ -0,0 +1,78 @@
+/*
+ * DNN - Data News Network
+ *
+ * by Stephane Chatty and Stephane Sire
+ *
+ * Copyright 1993-1996
+ * Centre d'Etudes de la Navigation Aerienne (CENA)
+ *
+ * Disposable objects.
+ *
+ * $Id$
+ * $CurLog$
+ */
+
+#include "Disposable.h"
+#include "Loop.h"
+
+bool DnnDisposable::ClassInitialized = false;
+CcuInitializerFor<DnnBaseMultiplexer> DnnDisposable::Dependance;
+CcuInitializerFor<DnnDisposable> DnnDisposable::Initializer;
+CcuListOf<DnnDisposable> DnnDisposable::Garbage;
+
+void
+DnnDisposable :: ClassInit ()
+{
+ if (!ClassInitialized) {
+ ClassInitialized = true;
+ DnnBaseMultiplexer::AddGlobalHook (&DnnDisposable::DeleteGarbage, true);
+ }
+}
+
+#if 0
+void
+DnnDisposable :: ClassClose ()
+{
+ DnnBaseMultiplexer::RemoveGlobalHook (&DnnDisposable::DeleteGarbage);
+}
+#endif
+
+
+/*?
+\typ{DnnDisposable} objects are objects whose deletion is called in a safe
+place in an asynchronous way.
+Instances of derived class of DnnDisposable which are to be deleted
+asynchronously must be allocated only dynamically with new.
+
+An instance is put into it's class garbage list (and thus deleted)
+by calling \fun{AsynchronousDelete} on itself.
+A mechanism of Lock and Unlock is also provided to prevent
+a deletion while in an unsafe state.
+
+Typically this class is to be used by derivation of UchChannel
+which can be deleted from within themselves after a call to \fun{HandleRead}.
+?*/
+DnnDisposable :: DnnDisposable ()
+{
+}
+
+DnnDisposable :: ~DnnDisposable ()
+{
+}
+
+void
+DnnDisposable :: Trash ()
+{
+ Garbage.Append (this);
+};
+
+/*?
+Delete all the instances which are in the garbage list.
+?*/
+void
+DnnDisposable :: DeleteGarbage ()
+{
+ DnnDisposable* d;
+ while (d = Garbage.RemoveFirst ())
+ delete d;
+}