blob: 86edcd70ec29e6feb148b9fe7867e01c4aa74b87 (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<html>
<head>
<!-- Generated by the Spirit (http://spirit.sf.net) C++ to HTML Converter -->
<title>
DefaultImpl.hpp</title>
<link rel="stylesheet" href="../../Documentation/Style/CXX.css" type="text/css"></head>
<body>
<pre>
<span class=comment>// file : Utility/ReferenceCounting/DefaultImpl.hpp
// author : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2002-2003 Boris Kolpackov
// license : http://kolpackov.net/license.html
</span><span class=keyword>namespace </span><span class=identifier>Utility
</span><span class=special>{
</span><span class=keyword>namespace </span><span class=identifier>ReferenceCounting
</span><span class=special>{
</span><span class=comment>// Default reference counter implementation with parameterised
// synchronization policy. It is assumed that none of the SynchPolicy
// types throw any logic exceptions. If in fact they do then these
// exceptions won't be handled and will be automatically converted
// to system exceptions.
</span><span class=keyword>template </span><span class=special><</span><span class=keyword>typename </span><span class=identifier>SynchPolicy </span><span class=special>= </span><span class=identifier>Utility</span><span class=special>::</span><span class=identifier>Synch</span><span class=special>::</span><span class=identifier>Policy</span><span class=special>::</span><span class=identifier>Null</span><span class=special>>
</span><span class=keyword>class </span><span class=identifier>DefaultImpl </span><span class=special>: </span><span class=keyword>public </span><span class=keyword>virtual </span><span class=identifier>Interface
</span><span class=special>{
</span><span class=keyword>public</span><span class=special>:
</span><span class=keyword>class </span><span class=identifier>InconsistentState_ </span><span class=special>{};
</span><span class=keyword>typedef
</span><span class=identifier>ExH</span><span class=special>::</span><span class=identifier>Compound</span><span class=special><</span><span class=identifier>InconsistentState_</span><span class=special>, </span><span class=identifier>Exception</span><span class=special>>
</span><span class=identifier>InconsistentState</span><span class=special>;
</span><span class=keyword>public</span><span class=special>:
</span><span class=identifier>DefaultImpl </span><span class=special>() </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>SystemException</span><span class=special>);
</span><span class=keyword>virtual
</span><span class=special>~</span><span class=identifier>DefaultImpl </span><span class=special>() </span><span class=keyword>throw </span><span class=special>();
</span><span class=keyword>public</span><span class=special>:
</span><span class=keyword>virtual </span><span class=keyword>void
</span><span class=identifier>add_ref </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
</span><span class=keyword>virtual </span><span class=keyword>void
</span><span class=identifier>remove_ref </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
</span><span class=keyword>virtual </span><span class=identifier>count_t
</span><span class=identifier>refcount_value </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
</span><span class=keyword>protected</span><span class=special>:
</span><span class=keyword>virtual </span><span class=keyword>void
</span><span class=identifier>add_ref_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
</span><span class=keyword>virtual </span><span class=keyword>bool
</span><span class=identifier>remove_ref_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
</span><span class=keyword>virtual </span><span class=identifier>count_t
</span><span class=identifier>refcount_value_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>(</span><span class=identifier>Exception</span><span class=special>, </span><span class=identifier>SystemException</span><span class=special>);
</span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>Mutex</span><span class=special>&
</span><span class=identifier>lock_i </span><span class=special>() </span><span class=keyword>const </span><span class=keyword>throw </span><span class=special>();
</span><span class=keyword>protected</span><span class=special>:
</span><span class=keyword>typedef
</span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>Mutex
</span><span class=identifier>Mutex_</span><span class=special>;
</span><span class=keyword>typedef
</span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>ReadGuard
</span><span class=identifier>ReadGuard_</span><span class=special>;
</span><span class=keyword>typedef
</span><span class=keyword>typename </span><span class=identifier>SynchPolicy</span><span class=special>::</span><span class=identifier>WriteGuard
</span><span class=identifier>WriteGuard_</span><span class=special>;
</span><span class=keyword>protected</span><span class=special>:
</span><span class=keyword>mutable </span><span class=identifier>count_t </span><span class=identifier>ref_count_</span><span class=special>;
</span><span class=keyword>private</span><span class=special>:
</span><span class=keyword>mutable </span><span class=identifier>Mutex_ </span><span class=identifier>lock_</span><span class=special>;
</span><span class=keyword>private</span><span class=special>:
</span><span class=comment>// Copy semanic is not supported.
</span><span class=identifier>DefaultImpl </span><span class=special>(</span><span class=identifier>DefaultImpl </span><span class=keyword>const</span><span class=special>&) </span><span class=keyword>throw </span><span class=special>();
</span><span class=identifier>DefaultImpl</span><span class=special>&
</span><span class=keyword>operator</span><span class=special>= </span><span class=special>(</span><span class=identifier>DefaultImpl </span><span class=keyword>const</span><span class=special>&) </span><span class=keyword>throw </span><span class=special>();
</span><span class=special>};
</span><span class=special>}
</span><span class=special>}
</span></pre>
</body>
</html>
<!-- $Id$ -->
|