wee 0.1.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +7 -0
- data/README +268 -0
- data/Rakefile +26 -0
- data/TODO +116 -0
- data/benchmark/Centrino1300/result.2000.counter.action +45 -0
- data/benchmark/Centrino1300/result.2000.counter.render +43 -0
- data/benchmark/Centrino1300/result.2000.filehandler +43 -0
- data/benchmark/Centrino600/result.2000.counter.action +47 -0
- data/benchmark/Centrino600/result.2000.counter.render +45 -0
- data/benchmark/Centrino600/result.2000.filehandler +43 -0
- data/benchmark/Makefile +48 -0
- data/benchmark/bench.sh +24 -0
- data/benchmark/counter.rb +96 -0
- data/benchmark/filehandler.rb +6 -0
- data/doc/rdoc/classes/Array.html +172 -0
- data/doc/rdoc/classes/Cache.html +126 -0
- data/doc/rdoc/classes/Cache/StorageCache.html +320 -0
- data/doc/rdoc/classes/Cache/Strategy.html +128 -0
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +269 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +225 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded/Item.html +111 -0
- data/doc/rdoc/classes/Enumerable.html +146 -0
- data/doc/rdoc/classes/LiteralMethod.html +196 -0
- data/doc/rdoc/classes/Object.html +178 -0
- data/doc/rdoc/classes/String.html +172 -0
- data/doc/rdoc/classes/Struct.html +174 -0
- data/doc/rdoc/classes/Wee.html +160 -0
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +182 -0
- data/doc/rdoc/classes/Wee/Application.html +337 -0
- data/doc/rdoc/classes/Wee/Brush.html +245 -0
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +157 -0
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +210 -0
- data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +225 -0
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +283 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +195 -0
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +172 -0
- data/doc/rdoc/classes/Wee/Brush/Page.html +193 -0
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +267 -0
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +177 -0
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +154 -0
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +173 -0
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +277 -0
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +229 -0
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +154 -0
- data/doc/rdoc/classes/Wee/Callback.html +231 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +308 -0
- data/doc/rdoc/classes/Wee/CallbackStream.html +227 -0
- data/doc/rdoc/classes/Wee/Canvas.html +235 -0
- data/doc/rdoc/classes/Wee/Component.html +933 -0
- data/doc/rdoc/classes/Wee/Context.html +111 -0
- data/doc/rdoc/classes/Wee/Decoration.html +338 -0
- data/doc/rdoc/classes/Wee/Delegate.html +247 -0
- data/doc/rdoc/classes/Wee/ErrorPage.html +175 -0
- data/doc/rdoc/classes/Wee/ErrorResponse.html +180 -0
- data/doc/rdoc/classes/Wee/GenericResponse.html +162 -0
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +751 -0
- data/doc/rdoc/classes/Wee/HtmlWriter.html +351 -0
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +180 -0
- data/doc/rdoc/classes/Wee/MethodCallback.html +193 -0
- data/doc/rdoc/classes/Wee/Page.html +111 -0
- data/doc/rdoc/classes/Wee/Presenter.html +521 -0
- data/doc/rdoc/classes/Wee/RedirectResponse.html +150 -0
- data/doc/rdoc/classes/Wee/RefreshResponse.html +157 -0
- data/doc/rdoc/classes/Wee/RenderingContext.html +111 -0
- data/doc/rdoc/classes/Wee/Request.html +268 -0
- data/doc/rdoc/classes/Wee/RequestHandler.html +336 -0
- data/doc/rdoc/classes/Wee/Response.html +260 -0
- data/doc/rdoc/classes/Wee/Session.html +469 -0
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +198 -0
- data/doc/rdoc/classes/Wee/Snapshot.html +211 -0
- data/doc/rdoc/classes/Wee/StateHolder.html +149 -0
- data/doc/rdoc/classes/Wee/StateRegistry.html +434 -0
- data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +320 -0
- data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +153 -0
- data/doc/rdoc/classes/Wee/Utils.html +111 -0
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +148 -0
- data/doc/rdoc/classes/Wee/ValueHolder.html +220 -0
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +330 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/INSTALL.html +118 -0
- data/doc/rdoc/files/README.html +466 -0
- data/doc/rdoc/files/lib/cache/cache_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/application_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/callback_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/component_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/component_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/context_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +115 -0
- data/doc/rdoc/files/lib/wee/core/component_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/core/decoration_rb.html +133 -0
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/core_rb.html +131 -0
- data/doc/rdoc/files/lib/wee/decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/holder_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/html_canvas_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/html_writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/idgen_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/page_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/request_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/response_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/session_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/snapshot_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/state_registry_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/stuff_rb.html +144 -0
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee_rb.html +132 -0
- data/doc/rdoc/fr_class_index.html +93 -0
- data/doc/rdoc/fr_file_index.html +51 -0
- data/doc/rdoc/fr_method_index.html +242 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/ObjectSpaceBrowser.rb +199 -0
- data/examples/calendar.rb +366 -0
- data/examples/cc.rb +94 -0
- data/examples/draw.rb +91 -0
- data/examples/example.rb +223 -0
- data/examples/test.rb +66 -0
- data/examples/window.rb +53 -0
- data/lib/cache/cache.rb +9 -0
- data/lib/wee.rb +18 -8
- data/lib/wee/adaptors/webrick.rb +73 -0
- data/lib/wee/application.rb +69 -71
- data/lib/wee/context.rb +2 -12
- data/lib/wee/core.rb +15 -0
- data/lib/wee/core/callback.rb +108 -0
- data/lib/wee/core/component.rb +314 -0
- data/lib/wee/core/decoration.rb +129 -0
- data/lib/wee/core/presenter.rb +132 -0
- data/lib/wee/core/snapshot.rb +21 -0
- data/lib/wee/core/valueholder.rb +19 -0
- data/lib/wee/idgen.rb +13 -0
- data/lib/wee/page.rb +1 -1
- data/lib/wee/renderer/html/brushes.rb +435 -0
- data/lib/wee/renderer/html/canvas.rb +148 -0
- data/lib/wee/{html_writer.rb → renderer/html/writer.rb} +31 -16
- data/lib/wee/request.rb +57 -0
- data/lib/wee/requesthandler.rb +77 -0
- data/lib/wee/response.rb +77 -0
- data/lib/wee/session.rb +70 -64
- data/lib/wee/{snapshot.rb → snapshot_ext.rb} +4 -4
- data/test/components/calltest.rb +16 -0
- data/test/components/counter.rb +17 -0
- data/test/components/messagebox.rb +15 -0
- data/test/components/page.rb +14 -0
- data/test/components/page_decoration.rb +7 -0
- data/test/stress.rb +64 -0
- data/test/test_component.rb +106 -0
- data/test/test_html_canvas.rb +25 -0
- data/test/test_html_writer.rb +27 -0
- data/test/test_request.rb +13 -0
- data/test/utils/cross.rb +65 -0
- data/test/utils/generic_plotter.rb +28 -0
- data/test/utils/gnuplot.rb +31 -0
- data/test/utils/measure_memory.rb +9 -0
- data/test/utils/memory_plotter.rb +10 -0
- data/test/utils/object_plotter.rb +10 -0
- data/test/utils/webrick_background.rb +31 -0
- data/wee.gemspec +22 -0
- metadata +222 -18
- data/lib/wee/component.rb +0 -126
- data/lib/wee/delegate_decoration.rb +0 -22
- data/lib/wee/handler_registry.rb +0 -89
- data/lib/wee/holder.rb +0 -14
- data/lib/wee/html_canvas.rb +0 -379
- data/lib/wee/state_registry.rb +0 -173
- data/lib/wee/stuff.rb +0 -29
- data/lib/wee/webrick.rb +0 -15
@@ -0,0 +1,434 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Wee::StateRegistry</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Wee::StateRegistry</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/wee/state_registry_rb.html">
|
59
|
+
lib/wee/state_registry.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="../Object.html">
|
69
|
+
Object
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
<a href="StateRegistry.html">StateRegistry</a> is not thread-safe! This
|
86
|
+
doesn’t matter, as each <a href="Session.html">Wee::Session</a> has
|
87
|
+
it’s own registry, and each session run’s in it’s own
|
88
|
+
thread.
|
89
|
+
</p>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<div id="method-list">
|
97
|
+
<h3 class="section-bar">Methods</h3>
|
98
|
+
|
99
|
+
<div class="name-list">
|
100
|
+
<a href="#M000044"><<</a>
|
101
|
+
<a href="#M000049">each_object</a>
|
102
|
+
<a href="#M000048">marshal_dump</a>
|
103
|
+
<a href="#M000047">marshal_load</a>
|
104
|
+
<a href="#M000042">new</a>
|
105
|
+
<a href="#M000043">register</a>
|
106
|
+
<a href="#M000045">snapshot</a>
|
107
|
+
<a href="#M000046">statistics</a>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
|
114
|
+
<!-- if includes -->
|
115
|
+
<div id="includes">
|
116
|
+
<h3 class="section-bar">Included Modules</h3>
|
117
|
+
|
118
|
+
<div id="includes-list">
|
119
|
+
<span class="include-name"><a href="StateRegistry/WithObject.html">WithObject</a></span>
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div id="section">
|
124
|
+
|
125
|
+
<div id="class-list">
|
126
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
127
|
+
|
128
|
+
Module <a href="StateRegistry/WithObject.html" class="link">Wee::StateRegistry::WithObject</a><br />
|
129
|
+
Class <a href="StateRegistry/Snapshot.html" class="link">Wee::StateRegistry::Snapshot</a><br />
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
<!-- if method_list -->
|
140
|
+
<div id="methods">
|
141
|
+
<h3 class="section-bar">Public Class methods</h3>
|
142
|
+
|
143
|
+
<div id="method-M000042" class="method-detail">
|
144
|
+
<a name="M000042"></a>
|
145
|
+
|
146
|
+
<div class="method-heading">
|
147
|
+
<a href="#M000042" class="method-signature">
|
148
|
+
<span class="method-name">new</span><span class="method-args">()</span>
|
149
|
+
</a>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div class="method-description">
|
153
|
+
<p><a class="source-toggle" href="#"
|
154
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
155
|
+
<div class="method-source-code" id="M000042-source">
|
156
|
+
<pre>
|
157
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 10</span>
|
158
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
159
|
+
<span class="ruby-ivar">@registered_objects</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># { oid => Set:{snap_oid1, snap_oid2}</span>
|
160
|
+
<span class="ruby-ivar">@snap_to_oid_map</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># { snap_oid => Set:{oid1, oid2} }</span>
|
161
|
+
|
162
|
+
<span class="ruby-ivar">@finalizer_snap</span> = <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">snap_oid</span><span class="ruby-operator">|</span>
|
163
|
+
<span class="ruby-ivar">@snap_to_oid_map</span>[<span class="ruby-identifier">snap_oid</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">oid</span><span class="ruby-operator">|</span>
|
164
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span> = <span class="ruby-ivar">@registered_objects</span>[<span class="ruby-identifier">oid</span>]
|
165
|
+
<span class="ruby-identifier">r</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">snap_oid</span>)
|
166
|
+
<span class="ruby-keyword kw">end</span>
|
167
|
+
<span class="ruby-keyword kw">end</span>
|
168
|
+
<span class="ruby-ivar">@snap_to_oid_map</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">snap_oid</span>)
|
169
|
+
}
|
170
|
+
|
171
|
+
<span class="ruby-ivar">@finalizer_obj</span> = <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">oid</span><span class="ruby-operator">|</span>
|
172
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span> = <span class="ruby-ivar">@registered_objects</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">oid</span>)
|
173
|
+
<span class="ruby-identifier">r</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">snap_oid</span><span class="ruby-operator">|</span>
|
174
|
+
<span class="ruby-identifier">with_object</span>(<span class="ruby-identifier">snap_oid</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">snap</span><span class="ruby-operator">|</span>
|
175
|
+
<span class="ruby-identifier">snap</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">oid</span>)
|
176
|
+
<span class="ruby-ivar">@snap_to_oid_map</span>[<span class="ruby-identifier">snap_oid</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">oid</span>)
|
177
|
+
}
|
178
|
+
<span class="ruby-keyword kw">end</span>
|
179
|
+
<span class="ruby-keyword kw">end</span>
|
180
|
+
}
|
181
|
+
<span class="ruby-keyword kw">end</span>
|
182
|
+
</pre>
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
</div>
|
186
|
+
|
187
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
188
|
+
|
189
|
+
<div id="method-M000044" class="method-detail">
|
190
|
+
<a name="M000044"></a>
|
191
|
+
|
192
|
+
<div class="method-heading">
|
193
|
+
<span class="method-name"><<</span><span class="method-args">(obj)</span>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
<p>
|
198
|
+
Alias for <a href="StateRegistry.html#M000043">register</a>
|
199
|
+
</p>
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
<div id="method-M000048" class="method-detail">
|
204
|
+
<a name="M000048"></a>
|
205
|
+
|
206
|
+
<div class="method-heading">
|
207
|
+
<a href="#M000048" class="method-signature">
|
208
|
+
<span class="method-name">marshal_dump</span><span class="method-args">()</span>
|
209
|
+
</a>
|
210
|
+
</div>
|
211
|
+
|
212
|
+
<div class="method-description">
|
213
|
+
<p>
|
214
|
+
Notice: We have to marshal the @registered_objects too, as we might have
|
215
|
+
not yet taken any snapshot
|
216
|
+
</p>
|
217
|
+
<p>
|
218
|
+
TODO: Should we do a GC before marshalling? Otherwise we marshal possibly
|
219
|
+
unused objects.
|
220
|
+
</p>
|
221
|
+
<p><a class="source-toggle" href="#"
|
222
|
+
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
223
|
+
<div class="method-source-code" id="M000048-source">
|
224
|
+
<pre>
|
225
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 100</span>
|
226
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshal_dump</span>
|
227
|
+
<span class="ruby-identifier">objs</span> = []
|
228
|
+
<span class="ruby-identifier">snaps</span> = []
|
229
|
+
|
230
|
+
<span class="ruby-identifier">each_object</span>(<span class="ruby-ivar">@registered_objects</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">obj</span>, <span class="ruby-identifier">oid</span><span class="ruby-operator">|</span> <span class="ruby-identifier">objs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">obj</span>}
|
231
|
+
<span class="ruby-identifier">each_object</span>(<span class="ruby-ivar">@snap_to_oid_map</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">snap</span>, <span class="ruby-identifier">soid</span><span class="ruby-operator">|</span> <span class="ruby-identifier">snaps</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">snap</span> }
|
232
|
+
|
233
|
+
[<span class="ruby-identifier">objs</span>, <span class="ruby-identifier">snaps</span>]
|
234
|
+
<span class="ruby-keyword kw">end</span>
|
235
|
+
</pre>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
</div>
|
239
|
+
|
240
|
+
<div id="method-M000047" class="method-detail">
|
241
|
+
<a name="M000047"></a>
|
242
|
+
|
243
|
+
<div class="method-heading">
|
244
|
+
<a href="#M000047" class="method-signature">
|
245
|
+
<span class="method-name">marshal_load</span><span class="method-args">(dump)</span>
|
246
|
+
</a>
|
247
|
+
</div>
|
248
|
+
|
249
|
+
<div class="method-description">
|
250
|
+
<hr size="10"></hr><p>
|
251
|
+
Marshalling
|
252
|
+
</p>
|
253
|
+
<hr size="10"></hr>
|
254
|
+
<p><a class="source-toggle" href="#"
|
255
|
+
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
256
|
+
<div class="method-source-code" id="M000047-source">
|
257
|
+
<pre>
|
258
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 74</span>
|
259
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshal_load</span>(<span class="ruby-identifier">dump</span>)
|
260
|
+
<span class="ruby-identifier">initialize</span>
|
261
|
+
<span class="ruby-identifier">objs</span>, <span class="ruby-identifier">snaps</span> = <span class="ruby-identifier">dump</span>
|
262
|
+
|
263
|
+
<span class="ruby-identifier">objs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
|
264
|
+
<span class="ruby-identifier">register</span>(<span class="ruby-identifier">obj</span>)
|
265
|
+
<span class="ruby-keyword kw">end</span>
|
266
|
+
|
267
|
+
<span class="ruby-identifier">snaps</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">snap</span><span class="ruby-operator">|</span>
|
268
|
+
<span class="ruby-identifier">set</span> = (<span class="ruby-ivar">@snap_to_oid_map</span>[<span class="ruby-identifier">snap</span>.<span class="ruby-identifier">object_id</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>)
|
269
|
+
|
270
|
+
<span class="ruby-identifier">snap</span>.<span class="ruby-identifier">data</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">oid</span>, <span class="ruby-identifier">hash</span><span class="ruby-operator">|</span>
|
271
|
+
<span class="ruby-identifier">set</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">oid</span>)
|
272
|
+
<span class="ruby-ivar">@registered_objects</span>[<span class="ruby-identifier">oid</span>].<span class="ruby-identifier">add</span>(<span class="ruby-identifier">snap</span>.<span class="ruby-identifier">object_id</span>)
|
273
|
+
<span class="ruby-keyword kw">end</span>
|
274
|
+
|
275
|
+
<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-identifier">snap</span>, <span class="ruby-ivar">@finalizer_snap</span>)
|
276
|
+
<span class="ruby-keyword kw">end</span>
|
277
|
+
<span class="ruby-keyword kw">end</span>
|
278
|
+
</pre>
|
279
|
+
</div>
|
280
|
+
</div>
|
281
|
+
</div>
|
282
|
+
|
283
|
+
<div id="method-M000043" class="method-detail">
|
284
|
+
<a name="M000043"></a>
|
285
|
+
|
286
|
+
<div class="method-heading">
|
287
|
+
<a href="#M000043" class="method-signature">
|
288
|
+
<span class="method-name">register</span><span class="method-args">(obj)</span>
|
289
|
+
</a>
|
290
|
+
</div>
|
291
|
+
|
292
|
+
<div class="method-description">
|
293
|
+
<p>
|
294
|
+
Register object <tt>obj</tt>. If you call <a
|
295
|
+
href="StateRegistry.html#M000045">snapshot</a>, a snapshot of all
|
296
|
+
registered objects is taken.
|
297
|
+
</p>
|
298
|
+
<p><a class="source-toggle" href="#"
|
299
|
+
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
300
|
+
<div class="method-source-code" id="M000043-source">
|
301
|
+
<pre>
|
302
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 38</span>
|
303
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">obj</span>)
|
304
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-value str">"multi-register"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@registered_objects</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>)
|
305
|
+
<span class="ruby-ivar">@registered_objects</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>
|
306
|
+
<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-ivar">@finalizer_obj</span>)
|
307
|
+
<span class="ruby-keyword kw">end</span>
|
308
|
+
</pre>
|
309
|
+
</div>
|
310
|
+
</div>
|
311
|
+
</div>
|
312
|
+
|
313
|
+
<div id="method-M000045" class="method-detail">
|
314
|
+
<a name="M000045"></a>
|
315
|
+
|
316
|
+
<div class="method-heading">
|
317
|
+
<a href="#M000045" class="method-signature">
|
318
|
+
<span class="method-name">snapshot</span><span class="method-args">()</span>
|
319
|
+
</a>
|
320
|
+
</div>
|
321
|
+
|
322
|
+
<div class="method-description">
|
323
|
+
<p>
|
324
|
+
Take a snapshot of all registered objects. Returns a <a
|
325
|
+
href="StateRegistry/Snapshot.html">StateRegistry::Snapshot</a> data
|
326
|
+
structure.
|
327
|
+
</p>
|
328
|
+
<p><a class="source-toggle" href="#"
|
329
|
+
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
330
|
+
<div class="method-source-code" id="M000045-source">
|
331
|
+
<pre>
|
332
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 48</span>
|
333
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">snapshot</span>
|
334
|
+
<span class="ruby-identifier">snap</span> = <span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">new</span>
|
335
|
+
<span class="ruby-identifier">snap_oid</span> = <span class="ruby-identifier">snap</span>.<span class="ruby-identifier">object_id</span>
|
336
|
+
<span class="ruby-identifier">set</span> = (<span class="ruby-ivar">@snap_to_oid_map</span>[<span class="ruby-identifier">snap</span>.<span class="ruby-identifier">object_id</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>)
|
337
|
+
|
338
|
+
<span class="ruby-identifier">each_object</span>(<span class="ruby-ivar">@registered_objects</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span>, <span class="ruby-identifier">oid</span><span class="ruby-operator">|</span>
|
339
|
+
<span class="ruby-identifier">snap</span>.<span class="ruby-identifier">add_object</span>(<span class="ruby-identifier">obj</span>)
|
340
|
+
<span class="ruby-identifier">set</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">oid</span>)
|
341
|
+
<span class="ruby-ivar">@registered_objects</span>[<span class="ruby-identifier">oid</span>].<span class="ruby-identifier">add</span>(<span class="ruby-identifier">snap_oid</span>)
|
342
|
+
<span class="ruby-keyword kw">end</span>
|
343
|
+
|
344
|
+
<span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-identifier">snap</span>, <span class="ruby-ivar">@finalizer_snap</span>)
|
345
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">snap</span>
|
346
|
+
<span class="ruby-keyword kw">end</span>
|
347
|
+
</pre>
|
348
|
+
</div>
|
349
|
+
</div>
|
350
|
+
</div>
|
351
|
+
|
352
|
+
<div id="method-M000046" class="method-detail">
|
353
|
+
<a name="M000046"></a>
|
354
|
+
|
355
|
+
<div class="method-heading">
|
356
|
+
<a href="#M000046" class="method-signature">
|
357
|
+
<span class="method-name">statistics</span><span class="method-args">()</span>
|
358
|
+
</a>
|
359
|
+
</div>
|
360
|
+
|
361
|
+
<div class="method-description">
|
362
|
+
<p>
|
363
|
+
Returns the current number of registered objects and snapshots.
|
364
|
+
</p>
|
365
|
+
<p><a class="source-toggle" href="#"
|
366
|
+
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
|
367
|
+
<div class="method-source-code" id="M000046-source">
|
368
|
+
<pre>
|
369
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 65</span>
|
370
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">statistics</span>
|
371
|
+
{<span class="ruby-identifier">:registered_objects</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@registered_objects</span>.<span class="ruby-identifier">size</span>,
|
372
|
+
<span class="ruby-identifier">:snapshots</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@snap_to_oid_map</span>.<span class="ruby-identifier">size</span>}
|
373
|
+
<span class="ruby-keyword kw">end</span>
|
374
|
+
</pre>
|
375
|
+
</div>
|
376
|
+
</div>
|
377
|
+
</div>
|
378
|
+
|
379
|
+
<h3 class="section-bar">Private Instance methods</h3>
|
380
|
+
|
381
|
+
<div id="method-M000049" class="method-detail">
|
382
|
+
<a name="M000049"></a>
|
383
|
+
|
384
|
+
<div class="method-heading">
|
385
|
+
<a href="#M000049" class="method-signature">
|
386
|
+
<span class="method-name">each_object</span><span class="method-args">(hash) {|object, object_id| ...}</span>
|
387
|
+
</a>
|
388
|
+
</div>
|
389
|
+
|
390
|
+
<div class="method-description">
|
391
|
+
<p>
|
392
|
+
Iterate over all live objects in <tt>hash</tt> where <tt>hash</tt> may be
|
393
|
+
either @registered_objects or @snap_to_oid_map.
|
394
|
+
</p>
|
395
|
+
<p><a class="source-toggle" href="#"
|
396
|
+
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
397
|
+
<div class="method-source-code" id="M000049-source">
|
398
|
+
<pre>
|
399
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 119</span>
|
400
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_object</span>(<span class="ruby-identifier">hash</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-comment cmt">#:yields: object, object_id</span>
|
401
|
+
<span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">oid</span><span class="ruby-operator">|</span>
|
402
|
+
<span class="ruby-identifier">with_object</span>(<span class="ruby-identifier">oid</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
|
403
|
+
|
404
|
+
<span class="ruby-comment cmt"># At this point, @registered_objects[oid] will not be modified, i.e. no</span>
|
405
|
+
<span class="ruby-comment cmt"># finalizer for oid will be called as we're holding a reference to it.</span>
|
406
|
+
<span class="ruby-comment cmt"># But we might hold a reference to a non-registered object (the</span>
|
407
|
+
<span class="ruby-comment cmt"># "original" registered object was garbage-collected and a new with the</span>
|
408
|
+
<span class="ruby-comment cmt"># same object_id sprang into existence). If it's a different object</span>
|
409
|
+
<span class="ruby-comment cmt"># than the registered one, then a finalizer was called during iterating</span>
|
410
|
+
<span class="ruby-comment cmt"># over @registered_objects (and has been removed from there in the</span>
|
411
|
+
<span class="ruby-comment cmt"># meanwhile).</span>
|
412
|
+
|
413
|
+
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">oid</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">oid</span>)
|
414
|
+
}
|
415
|
+
<span class="ruby-keyword kw">end</span>
|
416
|
+
<span class="ruby-keyword kw">end</span>
|
417
|
+
</pre>
|
418
|
+
</div>
|
419
|
+
</div>
|
420
|
+
</div>
|
421
|
+
|
422
|
+
|
423
|
+
</div>
|
424
|
+
|
425
|
+
|
426
|
+
</div>
|
427
|
+
|
428
|
+
|
429
|
+
<div id="validator-badges">
|
430
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
431
|
+
</div>
|
432
|
+
|
433
|
+
</body>
|
434
|
+
</html>
|
@@ -0,0 +1,320 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Wee::StateRegistry::Snapshot</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Wee::StateRegistry::Snapshot</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/wee/state_registry_rb.html">
|
59
|
+
lib/wee/state_registry.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="../../Object.html">
|
69
|
+
Object
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
<a href="Snapshot.html">Snapshot</a> is a private data structure used by <a
|
86
|
+
href="../StateRegistry.html">StateRegistry</a>. You SHOULD NOT use it
|
87
|
+
directly!
|
88
|
+
</p>
|
89
|
+
|
90
|
+
</div>
|
91
|
+
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
<div id="method-list">
|
96
|
+
<h3 class="section-bar">Methods</h3>
|
97
|
+
|
98
|
+
<div class="name-list">
|
99
|
+
<a href="#M000052">add_object</a>
|
100
|
+
<a href="#M000053">apply</a>
|
101
|
+
<a href="#M000056">each_object_snapshot</a>
|
102
|
+
<a href="#M000054">marshal_dump</a>
|
103
|
+
<a href="#M000055">marshal_load</a>
|
104
|
+
<a href="#M000051">new</a>
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
|
110
|
+
|
111
|
+
<!-- if includes -->
|
112
|
+
<div id="includes">
|
113
|
+
<h3 class="section-bar">Included Modules</h3>
|
114
|
+
|
115
|
+
<div id="includes-list">
|
116
|
+
<span class="include-name"><a href="WithObject.html">WithObject</a></span>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div id="section">
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
<div id="attribute-list">
|
127
|
+
<h3 class="section-bar">Attributes</h3>
|
128
|
+
|
129
|
+
<div class="name-list">
|
130
|
+
<table>
|
131
|
+
<tr class="top-aligned-row context-row">
|
132
|
+
<td class="context-item-name">data</td>
|
133
|
+
<td class="context-item-value"> [R] </td>
|
134
|
+
<td class="context-item-desc">
|
135
|
+
DO NOT access <tt>data</tt> directly!
|
136
|
+
|
137
|
+
</td>
|
138
|
+
</tr>
|
139
|
+
</table>
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<!-- if method_list -->
|
146
|
+
<div id="methods">
|
147
|
+
<h3 class="section-bar">Public Class methods</h3>
|
148
|
+
|
149
|
+
<div id="method-M000051" class="method-detail">
|
150
|
+
<a name="M000051"></a>
|
151
|
+
|
152
|
+
<div class="method-heading">
|
153
|
+
<a href="#M000051" class="method-signature">
|
154
|
+
<span class="method-name">new</span><span class="method-args">()</span>
|
155
|
+
</a>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div class="method-description">
|
159
|
+
<p><a class="source-toggle" href="#"
|
160
|
+
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
161
|
+
<div class="method-source-code" id="M000051-source">
|
162
|
+
<pre>
|
163
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 160</span>
|
164
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
165
|
+
<span class="ruby-ivar">@data</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-comment cmt"># { oid => snapshot, ... }</span>
|
166
|
+
<span class="ruby-keyword kw">end</span>
|
167
|
+
</pre>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
173
|
+
|
174
|
+
<div id="method-M000052" class="method-detail">
|
175
|
+
<a name="M000052"></a>
|
176
|
+
|
177
|
+
<div class="method-heading">
|
178
|
+
<a href="#M000052" class="method-signature">
|
179
|
+
<span class="method-name">add_object</span><span class="method-args">(obj)</span>
|
180
|
+
</a>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div class="method-description">
|
184
|
+
<p><a class="source-toggle" href="#"
|
185
|
+
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
186
|
+
<div class="method-source-code" id="M000052-source">
|
187
|
+
<pre>
|
188
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 164</span>
|
189
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_object</span>(<span class="ruby-identifier">obj</span>)
|
190
|
+
<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>] = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">take_snapshot</span>
|
191
|
+
<span class="ruby-keyword kw">end</span>
|
192
|
+
</pre>
|
193
|
+
</div>
|
194
|
+
</div>
|
195
|
+
</div>
|
196
|
+
|
197
|
+
<div id="method-M000053" class="method-detail">
|
198
|
+
<a name="M000053"></a>
|
199
|
+
|
200
|
+
<div class="method-heading">
|
201
|
+
<a href="#M000053" class="method-signature">
|
202
|
+
<span class="method-name">apply</span><span class="method-args">()</span>
|
203
|
+
</a>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
<div class="method-description">
|
207
|
+
<p><a class="source-toggle" href="#"
|
208
|
+
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
209
|
+
<div class="method-source-code" id="M000053-source">
|
210
|
+
<pre>
|
211
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 168</span>
|
212
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">apply</span>
|
213
|
+
<span class="ruby-identifier">each_object_snapshot</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span>, <span class="ruby-identifier">snap</span><span class="ruby-operator">|</span>
|
214
|
+
<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">apply_snapshot</span>(<span class="ruby-identifier">snap</span>)
|
215
|
+
<span class="ruby-keyword kw">end</span>
|
216
|
+
<span class="ruby-keyword kw">end</span>
|
217
|
+
</pre>
|
218
|
+
</div>
|
219
|
+
</div>
|
220
|
+
</div>
|
221
|
+
|
222
|
+
<div id="method-M000054" class="method-detail">
|
223
|
+
<a name="M000054"></a>
|
224
|
+
|
225
|
+
<div class="method-heading">
|
226
|
+
<a href="#M000054" class="method-signature">
|
227
|
+
<span class="method-name">marshal_dump</span><span class="method-args">()</span>
|
228
|
+
</a>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
<div class="method-description">
|
232
|
+
<p><a class="source-toggle" href="#"
|
233
|
+
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
234
|
+
<div class="method-source-code" id="M000054-source">
|
235
|
+
<pre>
|
236
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 174</span>
|
237
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshal_dump</span>
|
238
|
+
<span class="ruby-comment cmt"># generates a { obj => {instance variables} } hash</span>
|
239
|
+
<span class="ruby-identifier">dump</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
|
240
|
+
|
241
|
+
<span class="ruby-identifier">each_object_snapshot</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span>, <span class="ruby-identifier">snap</span><span class="ruby-operator">|</span>
|
242
|
+
<span class="ruby-identifier">dump</span>[<span class="ruby-identifier">obj</span>] = <span class="ruby-identifier">snap</span>
|
243
|
+
<span class="ruby-keyword kw">end</span>
|
244
|
+
|
245
|
+
<span class="ruby-identifier">dump</span>
|
246
|
+
<span class="ruby-keyword kw">end</span>
|
247
|
+
</pre>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<div id="method-M000055" class="method-detail">
|
253
|
+
<a name="M000055"></a>
|
254
|
+
|
255
|
+
<div class="method-heading">
|
256
|
+
<a href="#M000055" class="method-signature">
|
257
|
+
<span class="method-name">marshal_load</span><span class="method-args">(dump)</span>
|
258
|
+
</a>
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
<p><a class="source-toggle" href="#"
|
263
|
+
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
264
|
+
<div class="method-source-code" id="M000055-source">
|
265
|
+
<pre>
|
266
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 185</span>
|
267
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshal_load</span>(<span class="ruby-identifier">dump</span>)
|
268
|
+
<span class="ruby-identifier">initialize</span>
|
269
|
+
<span class="ruby-identifier">dump</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span>, <span class="ruby-identifier">hash</span><span class="ruby-operator">|</span>
|
270
|
+
<span class="ruby-ivar">@data</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>] = <span class="ruby-identifier">hash</span>
|
271
|
+
<span class="ruby-keyword kw">end</span>
|
272
|
+
<span class="ruby-keyword kw">end</span>
|
273
|
+
</pre>
|
274
|
+
</div>
|
275
|
+
</div>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
<h3 class="section-bar">Private Instance methods</h3>
|
279
|
+
|
280
|
+
<div id="method-M000056" class="method-detail">
|
281
|
+
<a name="M000056"></a>
|
282
|
+
|
283
|
+
<div class="method-heading">
|
284
|
+
<a href="#M000056" class="method-signature">
|
285
|
+
<span class="method-name">each_object_snapshot</span><span class="method-args">(&block)</span>
|
286
|
+
</a>
|
287
|
+
</div>
|
288
|
+
|
289
|
+
<div class="method-description">
|
290
|
+
<p><a class="source-toggle" href="#"
|
291
|
+
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
292
|
+
<div class="method-source-code" id="M000056-source">
|
293
|
+
<pre>
|
294
|
+
<span class="ruby-comment cmt"># File lib/wee/state_registry.rb, line 196</span>
|
295
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_object_snapshot</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
296
|
+
<span class="ruby-ivar">@data</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">oid</span>, <span class="ruby-identifier">snap</span><span class="ruby-operator">|</span>
|
297
|
+
<span class="ruby-identifier">with_object</span>(<span class="ruby-identifier">oid</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
|
298
|
+
<span class="ruby-comment cmt"># same is true as for StateRegistry#each_object</span>
|
299
|
+
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">snap</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">oid</span>)
|
300
|
+
}
|
301
|
+
<span class="ruby-keyword kw">end</span>
|
302
|
+
<span class="ruby-keyword kw">end</span>
|
303
|
+
</pre>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
</div>
|
307
|
+
|
308
|
+
|
309
|
+
</div>
|
310
|
+
|
311
|
+
|
312
|
+
</div>
|
313
|
+
|
314
|
+
|
315
|
+
<div id="validator-badges">
|
316
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
</body>
|
320
|
+
</html>
|