yunhe 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile +1 -0
  4. data/README.md +1 -0
  5. data/Rakefile +15 -0
  6. data/doc/Gemfile.html +87 -0
  7. data/doc/README_md.html +85 -0
  8. data/doc/Yunhe/Consumer.html +194 -0
  9. data/doc/Yunhe/Core.html +396 -0
  10. data/doc/Yunhe/Producer.html +194 -0
  11. data/doc/Yunhe.html +164 -0
  12. data/doc/created.rid +9 -0
  13. data/doc/css/fonts.css +167 -0
  14. data/doc/css/rdoc.css +590 -0
  15. data/doc/fonts/Lato-Light.ttf +0 -0
  16. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  17. data/doc/fonts/Lato-Regular.ttf +0 -0
  18. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  19. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  20. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  21. data/doc/images/add.png +0 -0
  22. data/doc/images/arrow_up.png +0 -0
  23. data/doc/images/brick.png +0 -0
  24. data/doc/images/brick_link.png +0 -0
  25. data/doc/images/bug.png +0 -0
  26. data/doc/images/bullet_black.png +0 -0
  27. data/doc/images/bullet_toggle_minus.png +0 -0
  28. data/doc/images/bullet_toggle_plus.png +0 -0
  29. data/doc/images/date.png +0 -0
  30. data/doc/images/delete.png +0 -0
  31. data/doc/images/find.png +0 -0
  32. data/doc/images/loadingAnimation.gif +0 -0
  33. data/doc/images/macFFBgHack.png +0 -0
  34. data/doc/images/package.png +0 -0
  35. data/doc/images/page_green.png +0 -0
  36. data/doc/images/page_white_text.png +0 -0
  37. data/doc/images/page_white_width.png +0 -0
  38. data/doc/images/plugin.png +0 -0
  39. data/doc/images/ruby.png +0 -0
  40. data/doc/images/tag_blue.png +0 -0
  41. data/doc/images/tag_green.png +0 -0
  42. data/doc/images/transparent.png +0 -0
  43. data/doc/images/wrench.png +0 -0
  44. data/doc/images/wrench_orange.png +0 -0
  45. data/doc/images/zoom.png +0 -0
  46. data/doc/index.html +101 -0
  47. data/doc/js/darkfish.js +161 -0
  48. data/doc/js/jquery.js +4 -0
  49. data/doc/js/navigation.js +142 -0
  50. data/doc/js/navigation.js.gz +0 -0
  51. data/doc/js/search.js +109 -0
  52. data/doc/js/search_index.js +1 -0
  53. data/doc/js/search_index.js.gz +0 -0
  54. data/doc/js/searcher.js +228 -0
  55. data/doc/js/searcher.js.gz +0 -0
  56. data/doc/table_of_contents.html +101 -0
  57. data/doc/yunhe_gemspec.html +105 -0
  58. data/lib/yunhe/consumer.rb +24 -0
  59. data/lib/yunhe/core.rb +111 -0
  60. data/lib/yunhe/producer.rb +21 -0
  61. data/lib/yunhe/version.rb +3 -0
  62. data/lib/yunhe.rb +20 -0
  63. data/yunhe.gemspec +18 -0
  64. metadata +107 -0
@@ -0,0 +1,396 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Yunhe::Core - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ </script>
12
+
13
+ <script src="../js/jquery.js"></script>
14
+ <script src="../js/darkfish.js"></script>
15
+
16
+ <link href="../css/fonts.css" rel="stylesheet">
17
+ <link href="../css/rdoc.css" rel="stylesheet">
18
+
19
+
20
+
21
+ <body id="top" role="document" class="class">
22
+ <nav role="navigation">
23
+ <div id="project-navigation">
24
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
25
+ <h2>
26
+ <a href="../index.html" rel="home">Home</a>
27
+ </h2>
28
+
29
+ <div id="table-of-contents-navigation">
30
+ <a href="../table_of_contents.html#pages">Pages</a>
31
+ <a href="../table_of_contents.html#classes">Classes</a>
32
+ <a href="../table_of_contents.html#methods">Methods</a>
33
+ </div>
34
+ </div>
35
+
36
+ <div id="search-section" role="search" class="project-section initially-hidden">
37
+ <form action="#" method="get" accept-charset="utf-8">
38
+ <div id="search-field-wrapper">
39
+ <input id="search-field" role="combobox" aria-label="Search"
40
+ aria-autocomplete="list" aria-controls="search-results"
41
+ type="text" name="search" placeholder="Search" spellcheck="false"
42
+ title="Type to search, Up and Down to navigate, Enter to load">
43
+ </div>
44
+
45
+ <ul id="search-results" aria-label="Search Results"
46
+ aria-busy="false" aria-expanded="false"
47
+ aria-atomic="false" class="initially-hidden"></ul>
48
+ </form>
49
+ </div>
50
+
51
+ </div>
52
+
53
+
54
+
55
+ <div id="class-metadata">
56
+
57
+ <div id="parent-class-section" class="nav-section">
58
+ <h3>Parent</h3>
59
+
60
+
61
+ <p class="link">Object
62
+
63
+ </div>
64
+
65
+
66
+
67
+ <!-- Method Quickref -->
68
+ <div id="method-list-section" class="nav-section">
69
+ <h3>Methods</h3>
70
+
71
+ <ul class="link-list" role="directory">
72
+
73
+ <li ><a href="#method-c-new">::new</a>
74
+
75
+ <li ><a href="#method-i-consume_with">#consume_with</a>
76
+
77
+ <li ><a href="#method-i-produce_by">#produce_by</a>
78
+
79
+ <li ><a href="#method-i-terminate">#terminate</a>
80
+
81
+ </ul>
82
+ </div>
83
+
84
+ </div>
85
+ </nav>
86
+
87
+ <main role="main" aria-labelledby="class-Yunhe::Core">
88
+ <h1 id="class-Yunhe::Core" class="class">
89
+ class Yunhe::Core
90
+ </h1>
91
+
92
+ <section class="description">
93
+
94
+ <p>The core class that manages the producers and consumers.</p>
95
+
96
+ </section>
97
+
98
+
99
+
100
+
101
+ <section id="5Buntitled-5D" class="documentation-section">
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <section class="attribute-method-details" class="method-section">
110
+ <header>
111
+ <h3>Attributes</h3>
112
+ </header>
113
+
114
+
115
+ <div id="attribute-i-consumer_pool" class="method-detail">
116
+ <div class="method-heading attribute-method-heading">
117
+ <span class="method-name">consumer_pool</span><span
118
+ class="attribute-access-type">[R]</span>
119
+ </div>
120
+
121
+ <div class="method-description">
122
+
123
+
124
+
125
+ </div>
126
+ </div>
127
+
128
+ <div id="attribute-i-consumer_size" class="method-detail">
129
+ <div class="method-heading attribute-method-heading">
130
+ <span class="method-name">consumer_size</span><span
131
+ class="attribute-access-type">[RW]</span>
132
+ </div>
133
+
134
+ <div class="method-description">
135
+
136
+
137
+
138
+ </div>
139
+ </div>
140
+
141
+ <div id="attribute-i-producer_pool" class="method-detail">
142
+ <div class="method-heading attribute-method-heading">
143
+ <span class="method-name">producer_pool</span><span
144
+ class="attribute-access-type">[R]</span>
145
+ </div>
146
+
147
+ <div class="method-description">
148
+
149
+
150
+
151
+ </div>
152
+ </div>
153
+
154
+ <div id="attribute-i-producer_size" class="method-detail">
155
+ <div class="method-heading attribute-method-heading">
156
+ <span class="method-name">producer_size</span><span
157
+ class="attribute-access-type">[RW]</span>
158
+ </div>
159
+
160
+ <div class="method-description">
161
+
162
+
163
+
164
+ </div>
165
+ </div>
166
+
167
+ <div id="attribute-i-queue" class="method-detail">
168
+ <div class="method-heading attribute-method-heading">
169
+ <span class="method-name">queue</span><span
170
+ class="attribute-access-type">[R]</span>
171
+ </div>
172
+
173
+ <div class="method-description">
174
+
175
+
176
+
177
+ </div>
178
+ </div>
179
+
180
+ <div id="attribute-i-queue_size" class="method-detail">
181
+ <div class="method-heading attribute-method-heading">
182
+ <span class="method-name">queue_size</span><span
183
+ class="attribute-access-type">[RW]</span>
184
+ </div>
185
+
186
+ <div class="method-description">
187
+
188
+
189
+
190
+ </div>
191
+ </div>
192
+
193
+ </section>
194
+
195
+
196
+
197
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
198
+ <header>
199
+ <h3>Public Class Methods</h3>
200
+ </header>
201
+
202
+
203
+ <div id="method-c-new" class="method-detail ">
204
+
205
+ <div class="method-heading">
206
+ <span class="method-name">new</span><span
207
+ class="method-args">(options)</span>
208
+
209
+ <span class="method-click-advice">click to toggle source</span>
210
+
211
+ </div>
212
+
213
+
214
+ <div class="method-description">
215
+
216
+ <p>Initialize a new yunhe core with options: :producer_size =&gt; Size of
217
+ the producer pool :consumer_size =&gt; Size of the consumer pool
218
+ :queue_size =&gt; Size of the buffer queue</p>
219
+
220
+
221
+
222
+
223
+ <div class="method-source-code" id="new-source">
224
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 19</span>
225
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>)
226
+ <span class="ruby-identifier">producer_size</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:producer_size</span>]
227
+ <span class="ruby-identifier">consumer_size</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:consumer_size</span>]
228
+ <span class="ruby-identifier">queue_size</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:queue_size</span>]
229
+
230
+ <span class="ruby-ivar">@producer_pool</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
231
+ <span class="ruby-ivar">@consumer_pool</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
232
+ <span class="ruby-ivar">@queue</span> = <span class="ruby-constant">SizedQueue</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queue_size</span>)
233
+ <span class="ruby-keyword">end</span></pre>
234
+ </div>
235
+
236
+ </div>
237
+
238
+
239
+
240
+
241
+ </div>
242
+
243
+
244
+ </section>
245
+
246
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
247
+ <header>
248
+ <h3>Public Instance Methods</h3>
249
+ </header>
250
+
251
+
252
+ <div id="method-i-consume_with" class="method-detail ">
253
+
254
+ <div class="method-heading">
255
+ <span class="method-name">consume_with</span><span
256
+ class="method-args">(&task)</span>
257
+
258
+ <span class="method-click-advice">click to toggle source</span>
259
+
260
+ </div>
261
+
262
+
263
+ <div class="method-description">
264
+
265
+ <p>Set the consumer task &amp;task: The task that procceed the resources.
266
+ Should take the resource as a paramater:</p>
267
+
268
+ <pre>do | resource |
269
+ ...
270
+ end</pre>
271
+
272
+
273
+
274
+
275
+ <div class="method-source-code" id="consume_with-source">
276
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 79</span>
277
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">consume_with</span> (<span class="ruby-operator">&amp;</span><span class="ruby-identifier">task</span>)
278
+ <span class="ruby-identifier">each_consumer</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">thread</span> <span class="ruby-operator">|</span>
279
+ <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
280
+ <span class="ruby-keyword">end</span>
281
+
282
+ <span class="ruby-identifier">consumer_size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
283
+ <span class="ruby-identifier">thread</span> = <span class="ruby-constant">Consumer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queue</span>, <span class="ruby-identifier">task</span>)
284
+ <span class="ruby-identifier">consumer_pool</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">thread</span>)
285
+ <span class="ruby-keyword">end</span>
286
+ <span class="ruby-keyword">end</span></pre>
287
+ </div>
288
+
289
+ </div>
290
+
291
+
292
+
293
+
294
+ </div>
295
+
296
+
297
+ <div id="method-i-produce_by" class="method-detail ">
298
+
299
+ <div class="method-heading">
300
+ <span class="method-name">produce_by</span><span
301
+ class="method-args">(&task)</span>
302
+
303
+ <span class="method-click-advice">click to toggle source</span>
304
+
305
+ </div>
306
+
307
+
308
+ <div class="method-description">
309
+
310
+ <p>Set the producer task &amp;task: The task that produces a new resource.
311
+ Should have the resource returned:</p>
312
+
313
+ <pre>do
314
+ ...
315
+ return resource
316
+ end</pre>
317
+
318
+
319
+
320
+
321
+ <div class="method-source-code" id="produce_by-source">
322
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 62</span>
323
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">produce_by</span> (<span class="ruby-operator">&amp;</span><span class="ruby-identifier">task</span>)
324
+ <span class="ruby-identifier">each_producer</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">thread</span> <span class="ruby-operator">|</span>
325
+ <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
326
+ <span class="ruby-keyword">end</span>
327
+
328
+ <span class="ruby-identifier">producer_size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
329
+ <span class="ruby-identifier">thread</span> = <span class="ruby-constant">Producer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queue</span>, <span class="ruby-identifier">task</span>)
330
+ <span class="ruby-identifier">producer_pool</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">thread</span>)
331
+ <span class="ruby-keyword">end</span>
332
+ <span class="ruby-keyword">end</span></pre>
333
+ </div>
334
+
335
+ </div>
336
+
337
+
338
+
339
+
340
+ </div>
341
+
342
+
343
+ <div id="method-i-terminate" class="method-detail ">
344
+
345
+ <div class="method-heading">
346
+ <span class="method-name">terminate</span><span
347
+ class="method-args">()</span>
348
+
349
+ <span class="method-click-advice">click to toggle source</span>
350
+
351
+ </div>
352
+
353
+
354
+ <div class="method-description">
355
+
356
+ <p>Stop the yunhe core. Kill all producer/consumer threads, and clear the
357
+ buffer queue.</p>
358
+
359
+
360
+
361
+
362
+ <div class="method-source-code" id="terminate-source">
363
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 91</span>
364
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">terminate</span>
365
+ <span class="ruby-identifier">each_producer</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">thread</span> <span class="ruby-operator">|</span>
366
+ <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
367
+ <span class="ruby-keyword">end</span>
368
+
369
+ <span class="ruby-identifier">each_consumer</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">thread</span> <span class="ruby-operator">|</span>
370
+ <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
371
+ <span class="ruby-keyword">end</span>
372
+
373
+ <span class="ruby-identifier">queue</span>.<span class="ruby-identifier">clear</span>
374
+ <span class="ruby-keyword">end</span></pre>
375
+ </div>
376
+
377
+ </div>
378
+
379
+
380
+
381
+
382
+ </div>
383
+
384
+
385
+ </section>
386
+
387
+ </section>
388
+ </main>
389
+
390
+
391
+ <footer id="validator-badges" role="contentinfo">
392
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
393
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
394
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
395
+ </footer>
396
+
@@ -0,0 +1,194 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Yunhe::Producer - RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../";
11
+ </script>
12
+
13
+ <script src="../js/jquery.js"></script>
14
+ <script src="../js/darkfish.js"></script>
15
+
16
+ <link href="../css/fonts.css" rel="stylesheet">
17
+ <link href="../css/rdoc.css" rel="stylesheet">
18
+
19
+
20
+
21
+ <body id="top" role="document" class="class">
22
+ <nav role="navigation">
23
+ <div id="project-navigation">
24
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
25
+ <h2>
26
+ <a href="../index.html" rel="home">Home</a>
27
+ </h2>
28
+
29
+ <div id="table-of-contents-navigation">
30
+ <a href="../table_of_contents.html#pages">Pages</a>
31
+ <a href="../table_of_contents.html#classes">Classes</a>
32
+ <a href="../table_of_contents.html#methods">Methods</a>
33
+ </div>
34
+ </div>
35
+
36
+ <div id="search-section" role="search" class="project-section initially-hidden">
37
+ <form action="#" method="get" accept-charset="utf-8">
38
+ <div id="search-field-wrapper">
39
+ <input id="search-field" role="combobox" aria-label="Search"
40
+ aria-autocomplete="list" aria-controls="search-results"
41
+ type="text" name="search" placeholder="Search" spellcheck="false"
42
+ title="Type to search, Up and Down to navigate, Enter to load">
43
+ </div>
44
+
45
+ <ul id="search-results" aria-label="Search Results"
46
+ aria-busy="false" aria-expanded="false"
47
+ aria-atomic="false" class="initially-hidden"></ul>
48
+ </form>
49
+ </div>
50
+
51
+ </div>
52
+
53
+
54
+
55
+ <div id="class-metadata">
56
+
57
+ <div id="parent-class-section" class="nav-section">
58
+ <h3>Parent</h3>
59
+
60
+
61
+ <p class="link">Thread
62
+
63
+ </div>
64
+
65
+
66
+
67
+ <!-- Method Quickref -->
68
+ <div id="method-list-section" class="nav-section">
69
+ <h3>Methods</h3>
70
+
71
+ <ul class="link-list" role="directory">
72
+
73
+ <li class="calls-super" ><a href="#method-c-new">::new</a>
74
+
75
+ </ul>
76
+ </div>
77
+
78
+ </div>
79
+ </nav>
80
+
81
+ <main role="main" aria-labelledby="class-Yunhe::Producer">
82
+ <h1 id="class-Yunhe::Producer" class="class">
83
+ class Yunhe::Producer
84
+ </h1>
85
+
86
+ <section class="description">
87
+
88
+ </section>
89
+
90
+
91
+
92
+
93
+ <section id="5Buntitled-5D" class="documentation-section">
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <section class="attribute-method-details" class="method-section">
102
+ <header>
103
+ <h3>Attributes</h3>
104
+ </header>
105
+
106
+
107
+ <div id="attribute-i-block" class="method-detail">
108
+ <div class="method-heading attribute-method-heading">
109
+ <span class="method-name">block</span><span
110
+ class="attribute-access-type">[RW]</span>
111
+ </div>
112
+
113
+ <div class="method-description">
114
+
115
+
116
+
117
+ </div>
118
+ </div>
119
+
120
+ <div id="attribute-i-queue" class="method-detail">
121
+ <div class="method-heading attribute-method-heading">
122
+ <span class="method-name">queue</span><span
123
+ class="attribute-access-type">[RW]</span>
124
+ </div>
125
+
126
+ <div class="method-description">
127
+
128
+
129
+
130
+ </div>
131
+ </div>
132
+
133
+ </section>
134
+
135
+
136
+
137
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
138
+ <header>
139
+ <h3>Public Class Methods</h3>
140
+ </header>
141
+
142
+
143
+ <div id="method-c-new" class="method-detail ">
144
+
145
+ <div class="method-heading">
146
+ <span class="method-name">new</span><span
147
+ class="method-args">(queue, block)</span>
148
+
149
+ <span class="method-click-advice">click to toggle source</span>
150
+
151
+ </div>
152
+
153
+
154
+ <div class="method-description">
155
+
156
+
157
+
158
+
159
+ <div class="method-calls-super">
160
+ Calls superclass method
161
+
162
+ </div>
163
+
164
+
165
+
166
+ <div class="method-source-code" id="new-source">
167
+ <pre><span class="ruby-comment"># File lib/yunhe/producer.rb, line 6</span>
168
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">queue</span>, <span class="ruby-identifier">block</span>)
169
+ <span class="ruby-keyword">super</span> <span class="ruby-operator">&amp;</span>(<span class="ruby-identifier">method</span>(<span class="ruby-value">:job</span>).<span class="ruby-identifier">to_proc</span>)
170
+ <span class="ruby-ivar">@block</span> = <span class="ruby-identifier">block</span>
171
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">queue</span> = <span class="ruby-identifier">queue</span>
172
+ <span class="ruby-keyword">end</span></pre>
173
+ </div>
174
+
175
+ </div>
176
+
177
+
178
+
179
+
180
+ </div>
181
+
182
+
183
+ </section>
184
+
185
+ </section>
186
+ </main>
187
+
188
+
189
+ <footer id="validator-badges" role="contentinfo">
190
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
191
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
192
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
193
+ </footer>
194
+