blob: 041931b3e295caba19a4f43132fc6504f2d8081b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* 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 IvlDisposable::ClassInitialized = false;
IvlInitializerFor<IvlBaseMultiplexer> IvlDisposable::Dependance;
IvlInitializerFor<IvlDisposable> IvlDisposable::Initializer;
IvlListOf<IvlDisposable> IvlDisposable::Garbage;
void
IvlDisposable :: ClassInit ()
{
if (!ClassInitialized) {
ClassInitialized = true;
IvlBaseMultiplexer::AddGlobalHook (&IvlDisposable::DeleteGarbage, true);
}
}
#if 0
void
IvlDisposable :: ClassClose ()
{
IvlBaseMultiplexer::RemoveGlobalHook (&IvlDisposable::DeleteGarbage);
}
#endif
/*?
\typ{IvlDisposable} objects are objects whose deletion is called in a safe
place in an asynchronous way.
Instances of derived class of IvlDisposable 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}.
?*/
IvlDisposable :: IvlDisposable ()
{
}
IvlDisposable :: ~IvlDisposable ()
{
}
void
IvlDisposable :: Trash ()
{
Garbage.Append (this);
};
/*?
Delete all the instances which are in the garbage list.
?*/
void
IvlDisposable :: DeleteGarbage ()
{
IvlDisposable* d;
while (d = Garbage.RemoveFirst ())
delete d;
}
|