slave 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,406 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Slave::LifeLine</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
+ <h1>Slave::LifeLine <sup class="type-note">(Class)</sup></h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>In:</strong></td>
54
+ <td>
55
+ <a href="../../files/lib/slave_rb.html">
56
+ lib/slave.rb
57
+ </a>
58
+ <br />
59
+ </td>
60
+ </tr>
61
+
62
+ <tr class="top-aligned-row">
63
+ <td><strong>Parent:</strong></td>
64
+ <td>
65
+ Object
66
+ </td>
67
+ </tr>
68
+ </table>
69
+ </div>
70
+ <!-- banner header -->
71
+
72
+ <div id="bodyContent">
73
+
74
+
75
+ <div id="contextContent">
76
+ <div id="diagram">
77
+ <map name="map">
78
+ <area shape="RECT" coords="123,98,195,50" href="../o.html" alt="o">
79
+ <area shape="RECT" coords="27,98,99,50" href="../Slave.html" alt="Slave">
80
+ </map>
81
+ <img src="../../dot/f_1.jpg" usemap="#map" border=0 alt="TopLevel">
82
+ </div>
83
+
84
+ <div id="description">
85
+ <p>
86
+ the <a href="LifeLine.html">LifeLine</a> class is used to communitacte
87
+ between child and parent processes and to prevent child processes from ever
88
+ becoming zombies or otherwise abandoned by their parents. the basic concept
89
+ is that a socket pair is setup between child and parent. the child process,
90
+ because it is a <a href="../Slave.html">Slave</a>, sets up a handler such
91
+ that, should it&#8217;s socket ever grow stale, will exit the process. this
92
+ class replaces the HeartBeat class from previous <a
93
+ href="../Slave.html">Slave</a> versions.
94
+ </p>
95
+
96
+ </div>
97
+
98
+
99
+ <div id="method-list">
100
+ <h2 class="section-bar">Methods</h2>
101
+
102
+ <div class="name-list">
103
+ <a href="#M000026">catch</a>&nbsp;&nbsp;
104
+ <a href="#M000030">cling</a>&nbsp;&nbsp;
105
+ <a href="#M000027">close_unused_sockets_after_forking</a>&nbsp;&nbsp;
106
+ <a href="#M000028">cut</a>&nbsp;&nbsp;
107
+ <a href="#M000023">new</a>&nbsp;&nbsp;
108
+ <a href="#M000029">on_cut</a>&nbsp;&nbsp;
109
+ <a href="#M000024">owner?</a>&nbsp;&nbsp;
110
+ <a href="#M000025">throw</a>&nbsp;&nbsp;
111
+ </div>
112
+ </div>
113
+
114
+ <div id="constants-list">
115
+ <h2 class="section-bar">Constants</h2>
116
+
117
+ <div class="name-list">
118
+ <table summary="Constants">
119
+ <tr class="top-aligned-row context-row">
120
+ <td class="context-item-name">FDS</td>
121
+ <td>=</td>
122
+ <td class="context-item-value">ThreadSafeHash.new</td>
123
+ </tr>
124
+ <tr class="top-aligned-row context-row">
125
+ <td class="context-item-name">DELEGATED</td>
126
+ <td>=</td>
127
+ <td class="context-item-value">%w( puts gets read write close flush each )</td>
128
+ </tr>
129
+ </table>
130
+ </div>
131
+ </div>
132
+
133
+ <div id="aliases-list">
134
+ <h2 class="section-bar">External Aliases</h2>
135
+
136
+ <div class="name-list">
137
+ "cut" -> "release" <br />
138
+ </div>
139
+ </div>
140
+
141
+
142
+
143
+
144
+ </div>
145
+
146
+
147
+
148
+ <!-- if includes -->
149
+
150
+
151
+ <!-- if method_list -->
152
+ <div id="methods">
153
+ <h2 class="section-bar">Public Class methods</h2>
154
+
155
+ <div id="method-M000023" class="method-detail">
156
+ <a name="M000023"></a>
157
+
158
+ <div class="method-heading">
159
+ <a href="#M000023" class="method-signature">
160
+ <span class="method-name">new</span><span class="method-args">()</span>
161
+ </a>
162
+ </div>
163
+
164
+ <div class="method-description">
165
+ <p><a class="source-toggle" href="#"
166
+ onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
167
+ <div class="method-source-code" id="M000023-source">
168
+ <pre>
169
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 171</span>
170
+ 171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
171
+ 172: <span class="ruby-ivar">@pair</span> = <span class="ruby-constant">Socket</span>.<span class="ruby-identifier">pair</span> <span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">AF_UNIX</span>, <span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">SOCK_STREAM</span>, <span class="ruby-value">0</span>
172
+ 173: <span class="ruby-ivar">@owner</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">pid</span>
173
+ 174: <span class="ruby-ivar">@pid</span> = <span class="ruby-keyword kw">nil</span>
174
+ 175: <span class="ruby-ivar">@socket</span> = <span class="ruby-keyword kw">nil</span>
175
+ 176: <span class="ruby-ivar">@object_id</span> = <span class="ruby-identifier">object_id</span>
176
+ 177:
177
+ 178: <span class="ruby-ivar">@fds</span> = <span class="ruby-ivar">@pair</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">fileno</span>}
178
+ 179: <span class="ruby-identifier">oid</span>, <span class="ruby-identifier">fds</span> = <span class="ruby-ivar">@object_id</span>, <span class="ruby-ivar">@fds</span>
179
+ 180: <span class="ruby-constant">FDS</span>[<span class="ruby-identifier">oid</span>] = <span class="ruby-identifier">fds</span>
180
+ 181: <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-keyword kw">self</span>){ <span class="ruby-constant">FDS</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">oid</span> }
181
+ 182: <span class="ruby-keyword kw">end</span>
182
+ </pre>
183
+ </div>
184
+ </div>
185
+ </div>
186
+
187
+ <h2 class="section-bar">Public Instance methods</h2>
188
+
189
+ <div id="method-M000026" class="method-detail">
190
+ <a name="M000026"></a>
191
+
192
+ <div class="method-heading">
193
+ <a href="#M000026" class="method-signature">
194
+ <span class="method-name">catch</span><span class="method-args">(*ignored)</span>
195
+ </a>
196
+ </div>
197
+
198
+ <div class="method-description">
199
+ <p><a class="source-toggle" href="#"
200
+ onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
201
+ <div class="method-source-code" id="M000026-source">
202
+ <pre>
203
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 197</span>
204
+ 197: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">catch</span> <span class="ruby-operator">*</span><span class="ruby-identifier">ignored</span>
205
+ 198: <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">owner?</span>
206
+ 199: <span class="ruby-ivar">@pair</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">close</span>
207
+ 200: <span class="ruby-ivar">@pair</span>[<span class="ruby-value">0</span>] = <span class="ruby-keyword kw">nil</span>
208
+ 201: <span class="ruby-ivar">@pid</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">pid</span>
209
+ 202: <span class="ruby-ivar">@socket</span> = <span class="ruby-ivar">@pair</span>[<span class="ruby-value">-1</span>]
210
+ 203: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">sync</span> = <span class="ruby-keyword kw">true</span>
211
+ 204: <span class="ruby-identifier">close_unused_sockets_after_forking</span>
212
+ 205: <span class="ruby-keyword kw">end</span>
213
+ </pre>
214
+ </div>
215
+ </div>
216
+ </div>
217
+
218
+ <div id="method-M000030" class="method-detail">
219
+ <a name="M000030"></a>
220
+
221
+ <div class="method-heading">
222
+ <a href="#M000030" class="method-signature">
223
+ <span class="method-name">cling</span><span class="method-args">(&amp;b)</span>
224
+ </a>
225
+ </div>
226
+
227
+ <div class="method-description">
228
+ <p><a class="source-toggle" href="#"
229
+ onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
230
+ <div class="method-source-code" id="M000030-source">
231
+ <pre>
232
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 266</span>
233
+ 266: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cling</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>
234
+ 267: <span class="ruby-identifier">on_cut</span>{ <span class="ruby-keyword kw">begin</span>; <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">b</span>; <span class="ruby-keyword kw">ensure</span>; <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">exit</span>; <span class="ruby-keyword kw">end</span> }.<span class="ruby-identifier">join</span>
235
+ 268: <span class="ruby-keyword kw">end</span>
236
+ </pre>
237
+ </div>
238
+ </div>
239
+ </div>
240
+
241
+ <div id="method-M000027" class="method-detail">
242
+ <a name="M000027"></a>
243
+
244
+ <div class="method-heading">
245
+ <a href="#M000027" class="method-signature">
246
+ <span class="method-name">close_unused_sockets_after_forking</span><span class="method-args">()</span>
247
+ </a>
248
+ </div>
249
+
250
+ <div class="method-description">
251
+ <p><a class="source-toggle" href="#"
252
+ onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
253
+ <div class="method-source-code" id="M000027-source">
254
+ <pre>
255
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 207</span>
256
+ 207: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close_unused_sockets_after_forking</span>
257
+ 208: <span class="ruby-keyword kw">begin</span>
258
+ 209: <span class="ruby-identifier">to_delete</span> = []
259
+ 210: <span class="ruby-keyword kw">begin</span>
260
+ 211: <span class="ruby-constant">FDS</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">fds</span><span class="ruby-operator">|</span>
261
+ 212: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">oid</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@object_id</span>
262
+ 213: <span class="ruby-keyword kw">begin</span>
263
+ 214: <span class="ruby-constant">IO</span>.<span class="ruby-identifier">for_fd</span>(<span class="ruby-identifier">fds</span>.<span class="ruby-identifier">first</span>).<span class="ruby-identifier">close</span>
264
+ 215: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
265
+ 216: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{ e.message } (#{ e.class })\n#{ e.backtrace.join 10.chr }&quot;</span>
266
+ 217: <span class="ruby-keyword kw">ensure</span>
267
+ 218: <span class="ruby-identifier">to_delete</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">oid</span>
268
+ 219: <span class="ruby-keyword kw">end</span>
269
+ 220: <span class="ruby-keyword kw">end</span>
270
+ 221: <span class="ruby-keyword kw">ensure</span>
271
+ 222: <span class="ruby-constant">FDS</span>.<span class="ruby-identifier">ex</span>{ <span class="ruby-identifier">to_delete</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">oid</span><span class="ruby-operator">|</span> <span class="ruby-constant">FDS</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">oid</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-value">42</span>} }
272
+ 223: <span class="ruby-keyword kw">end</span>
273
+ 224: <span class="ruby-constant">GC</span>.<span class="ruby-identifier">start</span>
274
+ 225: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
275
+ 226: <span class="ruby-value">42</span>
276
+ 227: <span class="ruby-keyword kw">end</span>
277
+ 228: <span class="ruby-keyword kw">end</span>
278
+ </pre>
279
+ </div>
280
+ </div>
281
+ </div>
282
+
283
+ <div id="method-M000028" class="method-detail">
284
+ <a name="M000028"></a>
285
+
286
+ <div class="method-heading">
287
+ <a href="#M000028" class="method-signature">
288
+ <span class="method-name">cut</span><span class="method-args">()</span>
289
+ </a>
290
+ </div>
291
+
292
+ <div class="method-description">
293
+ <p><a class="source-toggle" href="#"
294
+ onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
295
+ <div class="method-source-code" id="M000028-source">
296
+ <pre>
297
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 230</span>
298
+ 230: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cut</span>
299
+ 231: <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">owner?</span>
300
+ 232: <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@socket</span>
301
+ 233: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
302
+ 234: <span class="ruby-constant">FDS</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">object_id</span>
303
+ 235: <span class="ruby-keyword kw">end</span>
304
+ </pre>
305
+ </div>
306
+ </div>
307
+ </div>
308
+
309
+ <div id="method-M000029" class="method-detail">
310
+ <a name="M000029"></a>
311
+
312
+ <div class="method-heading">
313
+ <a href="#M000029" class="method-signature">
314
+ <span class="method-name">on_cut</span><span class="method-args">(&amp;b)</span>
315
+ </a>
316
+ </div>
317
+
318
+ <div class="method-description">
319
+ <p><a class="source-toggle" href="#"
320
+ onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
321
+ <div class="method-source-code" id="M000029-source">
322
+ <pre>
323
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 251</span>
324
+ 251: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">on_cut</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>
325
+ 252: <span class="ruby-identifier">at_exit</span>{ <span class="ruby-keyword kw">begin</span>; <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>; <span class="ruby-keyword kw">ensure</span>; <span class="ruby-identifier">b</span> = <span class="ruby-keyword kw">nil</span>; <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">b</span>}
326
+ 253: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">current</span><span class="ruby-operator">|</span>
327
+ 254: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>.<span class="ruby-identifier">abort_on_exception</span> = <span class="ruby-keyword kw">true</span>
328
+ 255: <span class="ruby-keyword kw">begin</span>
329
+ 256: <span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>}
330
+ 257: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span>
331
+ 258: <span class="ruby-identifier">current</span>.<span class="ruby-identifier">raise</span> <span class="ruby-identifier">$!</span>
332
+ 259: <span class="ruby-value">42</span>
333
+ 260: <span class="ruby-keyword kw">ensure</span>
334
+ 261: <span class="ruby-keyword kw">begin</span>; <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>; <span class="ruby-keyword kw">ensure</span>; <span class="ruby-identifier">b</span> = <span class="ruby-keyword kw">nil</span>; <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">b</span>
335
+ 262: <span class="ruby-keyword kw">end</span>
336
+ 263: }
337
+ 264: <span class="ruby-keyword kw">end</span>
338
+ </pre>
339
+ </div>
340
+ </div>
341
+ </div>
342
+
343
+ <div id="method-M000024" class="method-detail">
344
+ <a name="M000024"></a>
345
+
346
+ <div class="method-heading">
347
+ <a href="#M000024" class="method-signature">
348
+ <span class="method-name">owner?</span><span class="method-args">()</span>
349
+ </a>
350
+ </div>
351
+
352
+ <div class="method-description">
353
+ <p><a class="source-toggle" href="#"
354
+ onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
355
+ <div class="method-source-code" id="M000024-source">
356
+ <pre>
357
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 184</span>
358
+ 184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">owner?</span>
359
+ 185: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">pid</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@owner</span>
360
+ 186: <span class="ruby-keyword kw">end</span>
361
+ </pre>
362
+ </div>
363
+ </div>
364
+ </div>
365
+
366
+ <div id="method-M000025" class="method-detail">
367
+ <a name="M000025"></a>
368
+
369
+ <div class="method-heading">
370
+ <a href="#M000025" class="method-signature">
371
+ <span class="method-name">throw</span><span class="method-args">(*ignored)</span>
372
+ </a>
373
+ </div>
374
+
375
+ <div class="method-description">
376
+ <p><a class="source-toggle" href="#"
377
+ onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
378
+ <div class="method-source-code" id="M000025-source">
379
+ <pre>
380
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 188</span>
381
+ 188: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">throw</span> <span class="ruby-operator">*</span><span class="ruby-identifier">ignored</span>
382
+ 189: <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">owner?</span>
383
+ 190: <span class="ruby-ivar">@pair</span>[<span class="ruby-value">-1</span>].<span class="ruby-identifier">close</span>
384
+ 191: <span class="ruby-ivar">@pair</span>[<span class="ruby-value">-1</span>] = <span class="ruby-keyword kw">nil</span>
385
+ 192: <span class="ruby-ivar">@pid</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">pid</span>
386
+ 193: <span class="ruby-ivar">@socket</span> = <span class="ruby-ivar">@pair</span>[<span class="ruby-value">0</span>]
387
+ 194: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">sync</span> = <span class="ruby-keyword kw">true</span>
388
+ 195: <span class="ruby-keyword kw">end</span>
389
+ </pre>
390
+ </div>
391
+ </div>
392
+ </div>
393
+
394
+
395
+ </div>
396
+
397
+
398
+ </div>
399
+
400
+
401
+ <div id="validator-badges">
402
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
403
+ </div>
404
+
405
+ </body>
406
+ </html>
@@ -0,0 +1,284 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Slave::ThreadSafe</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
+ <h1>Slave::ThreadSafe <sup class="type-note">(Class)</sup></h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>In:</strong></td>
54
+ <td>
55
+ <a href="../../files/lib/slave_rb.html">
56
+ lib/slave.rb
57
+ </a>
58
+ <br />
59
+ </td>
60
+ </tr>
61
+
62
+ <tr class="top-aligned-row">
63
+ <td><strong>Parent:</strong></td>
64
+ <td>
65
+ Object
66
+ </td>
67
+ </tr>
68
+ </table>
69
+ </div>
70
+ <!-- banner header -->
71
+
72
+ <div id="bodyContent">
73
+
74
+
75
+ <div id="contextContent">
76
+ <div id="diagram">
77
+ <map name="map">
78
+ <area shape="RECT" coords="123,98,195,50" href="../o.html" alt="o">
79
+ <area shape="RECT" coords="27,98,99,50" href="../Slave.html" alt="Slave">
80
+ </map>
81
+ <img src="../../dot/f_1.jpg" usemap="#map" border=0 alt="TopLevel">
82
+ </div>
83
+
84
+ <div id="description">
85
+ <p>
86
+ <a href="ThreadSafe.html">ThreadSafe</a> is a delegate wrapper class used
87
+ for implementing gross thread safety around existing objects. when an
88
+ object is wrapped with this class as
89
+ </p>
90
+ <pre>
91
+ ts = ThreadSafe.new{ AnyObject.new }
92
+ </pre>
93
+ <p>
94
+ then ts can be used exactly as the normal object would have been, only all
95
+ calls are now thread safe. this is the mechanism behind the
96
+ &#8216;threadsafe&#8217;/:threadsafe keyword to Slave#initialize
97
+ </p>
98
+
99
+ </div>
100
+
101
+
102
+ <div id="method-list">
103
+ <h2 class="section-bar">Methods</h2>
104
+
105
+ <div class="name-list">
106
+ <a href="#M000022">class</a>&nbsp;&nbsp;
107
+ <a href="#M000018">ex</a>&nbsp;&nbsp;
108
+ <a href="#M000021">inspect</a>&nbsp;&nbsp;
109
+ <a href="#M000019">method_missing</a>&nbsp;&nbsp;
110
+ <a href="#M000017">new</a>&nbsp;&nbsp;
111
+ <a href="#M000020">respond_to?</a>&nbsp;&nbsp;
112
+ </div>
113
+ </div>
114
+
115
+
116
+
117
+
118
+
119
+
120
+ </div>
121
+
122
+
123
+
124
+ <!-- if includes -->
125
+
126
+
127
+ <!-- if method_list -->
128
+ <div id="methods">
129
+ <h2 class="section-bar">Public Class methods</h2>
130
+
131
+ <div id="method-M000017" class="method-detail">
132
+ <a name="M000017"></a>
133
+
134
+ <div class="method-heading">
135
+ <a href="#M000017" class="method-signature">
136
+ <span class="method-name">new</span><span class="method-args">object</span>
137
+ </a>
138
+ </div>
139
+
140
+ <div class="method-description">
141
+ <p><a class="source-toggle" href="#"
142
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
143
+ <div class="method-source-code" id="M000017-source">
144
+ <pre>
145
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 130</span>
146
+ 130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">object</span>
147
+ 131: <span class="ruby-ivar">@object</span> = <span class="ruby-identifier">object</span>
148
+ 132: <span class="ruby-ivar">@sync</span> = <span class="ruby-constant">Sync</span>.<span class="ruby-identifier">new</span>
149
+ 133: <span class="ruby-keyword kw">end</span>
150
+ </pre>
151
+ </div>
152
+ </div>
153
+ </div>
154
+
155
+ <h2 class="section-bar">Public Instance methods</h2>
156
+
157
+ <div id="method-M000022" class="method-detail">
158
+ <a name="M000022"></a>
159
+
160
+ <div class="method-heading">
161
+ <a href="#M000022" class="method-signature">
162
+ <span class="method-name">class</span><span class="method-args">()</span>
163
+ </a>
164
+ </div>
165
+
166
+ <div class="method-description">
167
+ <p><a class="source-toggle" href="#"
168
+ onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
169
+ <div class="method-source-code" id="M000022-source">
170
+ <pre>
171
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 146</span>
172
+ 146: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">class</span>
173
+ 147: <span class="ruby-identifier">ex</span>{ <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">class</span> }
174
+ 148: <span class="ruby-keyword kw">end</span>
175
+ </pre>
176
+ </div>
177
+ </div>
178
+ </div>
179
+
180
+ <div id="method-M000018" class="method-detail">
181
+ <a name="M000018"></a>
182
+
183
+ <div class="method-heading">
184
+ <a href="#M000018" class="method-signature">
185
+ <span class="method-name">ex</span><span class="method-args">() {|}| ...}</span>
186
+ </a>
187
+ </div>
188
+
189
+ <div class="method-description">
190
+ <p><a class="source-toggle" href="#"
191
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
192
+ <div class="method-source-code" id="M000018-source">
193
+ <pre>
194
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 134</span>
195
+ 134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ex</span>
196
+ 135: <span class="ruby-ivar">@sync</span>.<span class="ruby-identifier">synchronize</span>{ <span class="ruby-keyword kw">yield</span> }
197
+ 136: <span class="ruby-keyword kw">end</span>
198
+ </pre>
199
+ </div>
200
+ </div>
201
+ </div>
202
+
203
+ <div id="method-M000021" class="method-detail">
204
+ <a name="M000021"></a>
205
+
206
+ <div class="method-heading">
207
+ <a href="#M000021" class="method-signature">
208
+ <span class="method-name">inspect</span><span class="method-args">()</span>
209
+ </a>
210
+ </div>
211
+
212
+ <div class="method-description">
213
+ <p><a class="source-toggle" href="#"
214
+ onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
215
+ <div class="method-source-code" id="M000021-source">
216
+ <pre>
217
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 143</span>
218
+ 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
219
+ 144: <span class="ruby-identifier">ex</span>{ <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">inspect</span> }
220
+ 145: <span class="ruby-keyword kw">end</span>
221
+ </pre>
222
+ </div>
223
+ </div>
224
+ </div>
225
+
226
+ <div id="method-M000019" class="method-detail">
227
+ <a name="M000019"></a>
228
+
229
+ <div class="method-heading">
230
+ <a href="#M000019" class="method-signature">
231
+ <span class="method-name">method_missing</span><span class="method-args">m, *a, &amp;b</span>
232
+ </a>
233
+ </div>
234
+
235
+ <div class="method-description">
236
+ <p><a class="source-toggle" href="#"
237
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
238
+ <div class="method-source-code" id="M000019-source">
239
+ <pre>
240
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 137</span>
241
+ 137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span> <span class="ruby-identifier">m</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>
242
+ 138: <span class="ruby-identifier">ex</span>{ <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">m</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> }
243
+ 139: <span class="ruby-keyword kw">end</span>
244
+ </pre>
245
+ </div>
246
+ </div>
247
+ </div>
248
+
249
+ <div id="method-M000020" class="method-detail">
250
+ <a name="M000020"></a>
251
+
252
+ <div class="method-heading">
253
+ <a href="#M000020" class="method-signature">
254
+ <span class="method-name">respond_to?</span><span class="method-args">m</span>
255
+ </a>
256
+ </div>
257
+
258
+ <div class="method-description">
259
+ <p><a class="source-toggle" href="#"
260
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
261
+ <div class="method-source-code" id="M000020-source">
262
+ <pre>
263
+ <span class="ruby-comment cmt"># File lib/slave.rb, line 140</span>
264
+ 140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">m</span>
265
+ 141: <span class="ruby-identifier">ex</span>{ <span class="ruby-ivar">@object</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">m</span> }
266
+ 142: <span class="ruby-keyword kw">end</span>
267
+ </pre>
268
+ </div>
269
+ </div>
270
+ </div>
271
+
272
+
273
+ </div>
274
+
275
+
276
+ </div>
277
+
278
+
279
+ <div id="validator-badges">
280
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
281
+ </div>
282
+
283
+ </body>
284
+ </html>