yunhe 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b836128b64b47e8da0cf9f6f1c021f809c18379e
4
- data.tar.gz: ecf23559f6d277d0a8f43c63101ab274b2a3c444
3
+ metadata.gz: 4fa25c78ea5de26806b6c54b724a9a5be45eadb3
4
+ data.tar.gz: 7225f2a2ac264640af994535d20362ce9b461e68
5
5
  SHA512:
6
- metadata.gz: e08d680882d06c9e9a946cdf7b330f6ccaff4c4c19874ee2a8d9a97a84eb22b55855d76d74f9398b03059138978ad6e360fbb15a0b391bf536f0d21e2f6e125c
7
- data.tar.gz: c34b18a154297c0fab78a0cfb448630381f49df1cd34a08a951cf1e201b83bda224d1e568c6df3b67f81d0697410f2f4de20b1d93e6b19be9824d87de6e068b2
6
+ metadata.gz: a628ab51b65d08ba0371051953d07a20ba820f0ba1ac16000b5a5165fd3d17190e82bf867a7402b7325bfc1666506194e2ef86da2da9e330fb580687107cd8cc
7
+ data.tar.gz: 6fa61c38312ee4413a82733236c62ae00a3bbdf68e882ea6cd1fca73f7ef48eceec6ff4c7559ada7d6fe6ca3aab001fd79c7eb783c19959637c14a19c656dc68
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  # ignore generated gem
2
- *.gem
2
+ *.gem
3
+ doc/
4
+ **/.DS_Store
data/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2015 Karloku Sang
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1 +1,23 @@
1
- # Yunhe
1
+ # Yunhe:运河 - Canal
2
+ Yunhe is a light weight gem that implements the Producer/Consumer pattern using threads.
3
+ ## Installation
4
+ gem install yunhe
5
+ ## Usage
6
+ require 'yunhe'
7
+ # options
8
+ options = {
9
+ producer_size: 1, # size of producer thread pool
10
+ consumer_size: 5, # size of consumer thread pool
11
+ queue_size: 100 # size of buffer queue
12
+ }
13
+ yunhe = Yunhe.build(options)
14
+ yunhe.produce_by do
15
+ Time.now
16
+ # [Time.now, Time.now + 86400] # Each will be added to the buffer queue
17
+ end
18
+ yunhe.consume_with do |res|
19
+ puts res
20
+ end
21
+
22
+ # stop the canal
23
+ yunhe.terminate
data/doc/Gemfile.html CHANGED
@@ -62,6 +62,8 @@
62
62
 
63
63
  <li><a href="./README_md.html">README</a>
64
64
 
65
+ <li><a href="./Rakefile.html">Rakefile</a>
66
+
65
67
  <li><a href="./yunhe_gemspec.html">yunhe.gemspec</a>
66
68
 
67
69
  </ul>
@@ -73,8 +75,6 @@
73
75
  <main role="main" aria-label="Page Gemfile">
74
76
 
75
77
  <p>source &#39;<a href="https://ruby.taobao.org">ruby.taobao.org</a>&#39;</p>
76
-
77
- <p>gem &#39;minitest&#39;, :group =&gt; :test</p>
78
78
  </main>
79
79
 
80
80
 
data/doc/README_md.html CHANGED
@@ -51,6 +51,16 @@
51
51
  </div>
52
52
 
53
53
 
54
+ <div class="nav-section">
55
+ <h3>Table of Contents</h3>
56
+
57
+ <ul class="link-list" role="directory">
58
+ <li><a href="#label-Yunhe-3A-E8-BF-90-E6-B2-B3+-+Canal">Yunhe:运河 - Canal</a>
59
+ <li><a href="#label-Installation">Installation</a>
60
+ <li><a href="#label-Usage">Usage</a>
61
+ </ul>
62
+ </div>
63
+
54
64
 
55
65
  <div id="project-metadata">
56
66
  <div id="fileindex-section" class="nav-section">
@@ -62,6 +72,8 @@
62
72
 
63
73
  <li><a href="./README_md.html">README</a>
64
74
 
75
+ <li><a href="./Rakefile.html">Rakefile</a>
76
+
65
77
  <li><a href="./yunhe_gemspec.html">yunhe.gemspec</a>
66
78
 
67
79
  </ul>
@@ -72,7 +84,36 @@
72
84
 
73
85
  <main role="main" aria-label="Page README.md">
74
86
 
75
- <p><a href="Yunhe.html">Yunhe</a></p>
87
+ <h1 id="label-Yunhe-3A-E8-BF-90-E6-B2-B3+-+Canal">Yunhe:运河 - Canal<span><a href="#label-Yunhe-3A-E8-BF-90-E6-B2-B3+-+Canal">&para;</a> <a href="#top">&uarr;</a></span></h1>
88
+
89
+ <p><a href="Yunhe.html">Yunhe</a> is a light weight gem that implements the
90
+ Producer/Consumer pattern using threads.</p>
91
+
92
+ <h2 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#top">&uarr;</a></span></h2>
93
+
94
+ <pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">yunhe</span>
95
+ </pre>
96
+
97
+ <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
98
+
99
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;yunhe&#39;</span>
100
+ <span class="ruby-comment"># options</span>
101
+ <span class="ruby-identifier">options</span> = {
102
+ <span class="ruby-identifier">producer_size</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>, <span class="ruby-comment"># size of producer thread pool</span>
103
+ <span class="ruby-identifier">consumer_size</span><span class="ruby-operator">:</span> <span class="ruby-value">5</span>, <span class="ruby-comment"># size of consumer thread pool</span>
104
+ <span class="ruby-identifier">queue_size</span><span class="ruby-operator">:</span> <span class="ruby-value">100</span> <span class="ruby-comment"># size of buffer queue</span>
105
+ }
106
+ <span class="ruby-identifier">yunhe</span> = <span class="ruby-constant">Yunhe</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">options</span>)
107
+ <span class="ruby-identifier">yunhe</span>.<span class="ruby-identifier">produce_by</span> <span class="ruby-keyword">do</span>
108
+ <span class="ruby-constant">Date</span>.<span class="ruby-identifier">now</span>
109
+ <span class="ruby-keyword">end</span>
110
+ <span class="ruby-identifier">yunhe</span>.<span class="ruby-identifier">consume_with</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
111
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">res</span>
112
+ <span class="ruby-keyword">end</span>
113
+
114
+ <span class="ruby-comment"># stop the canal</span>
115
+ <span class="ruby-identifier">yunhe</span>.<span class="ruby-identifier">terminate</span>
116
+ </pre>
76
117
  </main>
77
118
 
78
119
 
data/doc/Yunhe.html CHANGED
@@ -63,7 +63,7 @@
63
63
 
64
64
  <ul class="link-list" role="directory">
65
65
 
66
- <li ><a href="#method-i-build">#build</a>
66
+ <li ><a href="#method-c-build">::build</a>
67
67
 
68
68
  </ul>
69
69
  </div>
@@ -112,13 +112,13 @@
112
112
 
113
113
 
114
114
 
115
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
115
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
116
116
  <header>
117
- <h3>Public Instance Methods</h3>
117
+ <h3>Public Class Methods</h3>
118
118
  </header>
119
119
 
120
120
 
121
- <div id="method-i-build" class="method-detail ">
121
+ <div id="method-c-build" class="method-detail ">
122
122
 
123
123
  <div class="method-heading">
124
124
  <span class="method-name">build</span><span
@@ -138,7 +138,9 @@
138
138
 
139
139
  <div class="method-source-code" id="build-source">
140
140
  <pre><span class="ruby-comment"># File lib/yunhe.rb, line 15</span>
141
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">build</span>(<span class="ruby-identifier">options</span>={})
141
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">options</span>={})
142
+ <span class="ruby-identifier">options</span> = <span class="ruby-constant">DEFAULT_OPTIONS</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
143
+ <span class="ruby-keyword">return</span> <span class="ruby-constant">Core</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
142
144
  <span class="ruby-keyword">end</span></pre>
143
145
  </div>
144
146
 
@@ -153,7 +153,8 @@
153
153
 
154
154
  <div class="method-description">
155
155
 
156
-
156
+ <p>Initialize a new consumer queue: the reference of the buffer queue block:
157
+ the task to process the resource</p>
157
158
 
158
159
 
159
160
  <div class="method-calls-super">
@@ -164,7 +165,7 @@
164
165
 
165
166
 
166
167
  <div class="method-source-code" id="new-source">
167
- <pre><span class="ruby-comment"># File lib/yunhe/consumer.rb, line 6</span>
168
+ <pre><span class="ruby-comment"># File lib/yunhe/consumer.rb, line 10</span>
168
169
  <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
170
  <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
171
  <span class="ruby-ivar">@block</span> = <span class="ruby-identifier">block</span>
data/doc/Yunhe/Core.html CHANGED
@@ -221,11 +221,11 @@ the producer pool :consumer_size =&gt; Size of the consumer pool
221
221
 
222
222
 
223
223
  <div class="method-source-code" id="new-source">
224
- <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 19</span>
224
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 18</span>
225
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>]
226
+ <span class="ruby-ivar">@producer_size</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:producer_size</span>]
227
+ <span class="ruby-ivar">@consumer_size</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:consumer_size</span>]
228
+ <span class="ruby-ivar">@queue_size</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:queue_size</span>]
229
229
 
230
230
  <span class="ruby-ivar">@producer_pool</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
231
231
  <span class="ruby-ivar">@consumer_pool</span> = <span class="ruby-constant">ThreadGroup</span>.<span class="ruby-identifier">new</span>
@@ -262,7 +262,7 @@ the producer pool :consumer_size =&gt; Size of the consumer pool
262
262
 
263
263
  <div class="method-description">
264
264
 
265
- <p>Set the consumer task &amp;task: The task that procceed the resources.
265
+ <p>Set the consumer task &amp;task: The task that process the resources.
266
266
  Should take the resource as a paramater:</p>
267
267
 
268
268
  <pre>do | resource |
@@ -273,7 +273,7 @@ end</pre>
273
273
 
274
274
 
275
275
  <div class="method-source-code" id="consume_with-source">
276
- <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 79</span>
276
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 78</span>
277
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
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
279
  <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
@@ -319,7 +319,7 @@ end</pre>
319
319
 
320
320
 
321
321
  <div class="method-source-code" id="produce_by-source">
322
- <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 62</span>
322
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 61</span>
323
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
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
325
  <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
@@ -360,7 +360,7 @@ buffer queue.</p>
360
360
 
361
361
 
362
362
  <div class="method-source-code" id="terminate-source">
363
- <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 91</span>
363
+ <pre><span class="ruby-comment"># File lib/yunhe/core.rb, line 90</span>
364
364
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">terminate</span>
365
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
366
  <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">kill</span>
data/doc/created.rid CHANGED
@@ -1,9 +1,11 @@
1
- Wed, 01 Apr 2015 16:01:46 +0800
2
- ./Gemfile Wed, 01 Apr 2015 15:36:47 +0800
3
- ./lib/yunhe/consumer.rb Wed, 01 Apr 2015 15:54:46 +0800
4
- ./lib/yunhe/core.rb Wed, 01 Apr 2015 15:54:24 +0800
1
+ Wed, 01 Apr 2015 19:18:26 +0800
2
+ ./Gemfile Wed, 01 Apr 2015 16:23:55 +0800
3
+ ./lib/yunhe/consumer.rb Wed, 01 Apr 2015 16:08:19 +0800
4
+ ./lib/yunhe/core.rb Wed, 01 Apr 2015 16:19:46 +0800
5
5
  ./lib/yunhe/producer.rb Wed, 01 Apr 2015 15:54:41 +0800
6
6
  ./lib/yunhe/version.rb Tue, 31 Mar 2015 15:55:32 +0800
7
- ./lib/yunhe.rb Wed, 01 Apr 2015 15:48:26 +0800
8
- ./README.md Wed, 01 Apr 2015 15:39:44 +0800
7
+ ./lib/yunhe.rb Wed, 01 Apr 2015 16:16:46 +0800
8
+ ./Rakefile Wed, 01 Apr 2015 17:46:22 +0800
9
+ ./README.md Wed, 01 Apr 2015 19:17:57 +0800
10
+ ./yunhe-0.0.1.gem Wed, 01 Apr 2015 19:16:56 +0800
9
11
  ./yunhe.gemspec Wed, 01 Apr 2015 15:38:25 +0800
data/doc/index.html CHANGED
@@ -61,6 +61,8 @@
61
61
 
62
62
  <li><a href="./README_md.html">README</a>
63
63
 
64
+ <li><a href="./Rakefile.html">Rakefile</a>
65
+
64
66
  <li><a href="./yunhe_gemspec.html">yunhe.gemspec</a>
65
67
 
66
68
  </ul>
@@ -88,7 +90,36 @@
88
90
  <main role="main">
89
91
 
90
92
 
91
- <p><a href="Yunhe.html">Yunhe</a></p>
93
+ <h1 id="label-Yunhe-3A-E8-BF-90-E6-B2-B3+-+Canal">Yunhe:运河 - Canal<span><a href="#label-Yunhe-3A-E8-BF-90-E6-B2-B3+-+Canal">&para;</a> <a href="#top">&uarr;</a></span></h1>
94
+
95
+ <p><a href="Yunhe.html">Yunhe</a> is a light weight gem that implements the
96
+ Producer/Consumer pattern using threads.</p>
97
+
98
+ <h2 id="label-Installation">Installation<span><a href="#label-Installation">&para;</a> <a href="#top">&uarr;</a></span></h2>
99
+
100
+ <pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">yunhe</span>
101
+ </pre>
102
+
103
+ <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
104
+
105
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;yunhe&#39;</span>
106
+ <span class="ruby-comment"># options</span>
107
+ <span class="ruby-identifier">options</span> = {
108
+ <span class="ruby-identifier">producer_size</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>, <span class="ruby-comment"># size of producer thread pool</span>
109
+ <span class="ruby-identifier">consumer_size</span><span class="ruby-operator">:</span> <span class="ruby-value">5</span>, <span class="ruby-comment"># size of consumer thread pool</span>
110
+ <span class="ruby-identifier">queue_size</span><span class="ruby-operator">:</span> <span class="ruby-value">100</span> <span class="ruby-comment"># size of buffer queue</span>
111
+ }
112
+ <span class="ruby-identifier">yunhe</span> = <span class="ruby-constant">Yunhe</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">options</span>)
113
+ <span class="ruby-identifier">yunhe</span>.<span class="ruby-identifier">produce_by</span> <span class="ruby-keyword">do</span>
114
+ <span class="ruby-constant">Date</span>.<span class="ruby-identifier">now</span>
115
+ <span class="ruby-keyword">end</span>
116
+ <span class="ruby-identifier">yunhe</span>.<span class="ruby-identifier">consume_with</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span>
117
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">res</span>
118
+ <span class="ruby-keyword">end</span>
119
+
120
+ <span class="ruby-comment"># stop the canal</span>
121
+ <span class="ruby-identifier">yunhe</span>.<span class="ruby-identifier">terminate</span>
122
+ </pre>
92
123
  </main>
93
124
 
94
125
 
@@ -1 +1 @@
1
- var search_data = {"index":{"searchIndex":["yunhe","consumer","core","producer","build()","consume_with()","new()","new()","new()","produce_by()","terminate()","gemfile","readme","yunhe.gemspec"],"longSearchIndex":["yunhe","yunhe::consumer","yunhe::core","yunhe::producer","yunhe#build()","yunhe::core#consume_with()","yunhe::consumer::new()","yunhe::core::new()","yunhe::producer::new()","yunhe::core#produce_by()","yunhe::core#terminate()","","",""],"info":[["Yunhe","","Yunhe.html","",""],["Yunhe::Consumer","","Yunhe/Consumer.html","",""],["Yunhe::Core","","Yunhe/Core.html","","<p>The core class that manages the producers and consumers.\n"],["Yunhe::Producer","","Yunhe/Producer.html","",""],["build","Yunhe","Yunhe.html#method-i-build","(options={})",""],["consume_with","Yunhe::Core","Yunhe/Core.html#method-i-consume_with","(&task)","<p>Set the consumer task &amp;task: The task that procceed the resources.\nShould take the resource as a …\n"],["new","Yunhe::Consumer","Yunhe/Consumer.html#method-c-new","(queue, block)",""],["new","Yunhe::Core","Yunhe/Core.html#method-c-new","(options)","<p>Initialize a new yunhe core with options: :producer_size =&gt; Size of\nthe producer pool :consumer_size …\n"],["new","Yunhe::Producer","Yunhe/Producer.html#method-c-new","(queue, block)",""],["produce_by","Yunhe::Core","Yunhe/Core.html#method-i-produce_by","(&task)","<p>Set the producer task &amp;task: The task that produces a new resource.\nShould have the resource returned: …\n"],["terminate","Yunhe::Core","Yunhe/Core.html#method-i-terminate","()","<p>Stop the yunhe core. Kill all producer/consumer threads, and clear the\nbuffer queue.\n"],["Gemfile","","Gemfile.html","","<p>source &#39;ruby.taobao.org&#39;\n<p>gem &#39;minitest&#39;, :group =&gt; :test\n"],["README","","README_md.html","","<p>Yunhe\n"],["yunhe.gemspec","","yunhe_gemspec.html","","<p>$LOAD_PATH.push File.expand_path(&#39;../lib&#39;, __FILE__) require\n&#39;yunhe/version&#39;\n<p>Gem::Specification.new …\n"]]}}
1
+ var search_data = {"index":{"searchIndex":["yunhe","consumer","core","producer","build()","consume_with()","new()","new()","new()","produce_by()","terminate()","gemfile","readme","rakefile","yunhe.gemspec"],"longSearchIndex":["yunhe","yunhe::consumer","yunhe::core","yunhe::producer","yunhe::build()","yunhe::core#consume_with()","yunhe::consumer::new()","yunhe::core::new()","yunhe::producer::new()","yunhe::core#produce_by()","yunhe::core#terminate()","","","",""],"info":[["Yunhe","","Yunhe.html","",""],["Yunhe::Consumer","","Yunhe/Consumer.html","",""],["Yunhe::Core","","Yunhe/Core.html","","<p>The core class that manages the producers and consumers.\n"],["Yunhe::Producer","","Yunhe/Producer.html","",""],["build","Yunhe","Yunhe.html#method-c-build","(options={})",""],["consume_with","Yunhe::Core","Yunhe/Core.html#method-i-consume_with","(&task)","<p>Set the consumer task &amp;task: The task that process the resources.\nShould take the resource as a paramater: …\n"],["new","Yunhe::Consumer","Yunhe/Consumer.html#method-c-new","(queue, block)","<p>Initialize a new consumer queue: the reference of the buffer queue block:\nthe task to process the resource …\n"],["new","Yunhe::Core","Yunhe/Core.html#method-c-new","(options)","<p>Initialize a new yunhe core with options: :producer_size =&gt; Size of\nthe producer pool :consumer_size …\n"],["new","Yunhe::Producer","Yunhe/Producer.html#method-c-new","(queue, block)",""],["produce_by","Yunhe::Core","Yunhe/Core.html#method-i-produce_by","(&task)","<p>Set the producer task &amp;task: The task that produces a new resource.\nShould have the resource returned: …\n"],["terminate","Yunhe::Core","Yunhe/Core.html#method-i-terminate","()","<p>Stop the yunhe core. Kill all producer/consumer threads, and clear the\nbuffer queue.\n"],["Gemfile","","Gemfile.html","","<p>source &#39;ruby.taobao.org&#39;\n"],["README","","README_md.html","","<p>Yunhe:运河 - Canal\n<p>Yunhe is a light weight gem that implements the Producer/Consumer pattern\nusing threads. …\n"],["Rakefile","","Rakefile.html","","<p>task :build do\n\n<pre>IO.popen &quot;gem build ./yunhe.gemspec&quot; do |f|\n while line = f.gets do\n puts line\n end ...</pre>\n"],["yunhe.gemspec","","yunhe_gemspec.html","","<p>$LOAD_PATH.push File.expand_path(&#39;../lib&#39;, __FILE__) require\n&#39;yunhe/version&#39;\n<p>Gem::Specification.new …\n"]]}}
Binary file
@@ -29,6 +29,15 @@
29
29
  </li>
30
30
  <li class="file">
31
31
  <a href="README_md.html">README</a>
32
+
33
+ <ul>
34
+ <li><a href="README_md.html#label-Yunhe-3A-E8-BF-90-E6-B2-B3+-+Canal">Yunhe:运河 - Canal</a>
35
+ <li><a href="README_md.html#label-Installation">Installation</a>
36
+ <li><a href="README_md.html#label-Usage">Usage</a>
37
+ </ul>
38
+ </li>
39
+ <li class="file">
40
+ <a href="Rakefile.html">Rakefile</a>
32
41
  </li>
33
42
  <li class="file">
34
43
  <a href="yunhe_gemspec.html">yunhe.gemspec</a>
@@ -56,9 +65,9 @@
56
65
  <ul>
57
66
 
58
67
  <li class="method">
59
- <a href="Yunhe/Consumer.html#method-c-new">::new</a>
68
+ <a href="Yunhe.html#method-c-build">::build</a>
60
69
  &mdash;
61
- <span class="container">Yunhe::Consumer</span>
70
+ <span class="container">Yunhe</span>
62
71
 
63
72
  <li class="method">
64
73
  <a href="Yunhe/Core.html#method-c-new">::new</a>
@@ -71,9 +80,9 @@
71
80
  <span class="container">Yunhe::Producer</span>
72
81
 
73
82
  <li class="method">
74
- <a href="Yunhe.html#method-i-build">#build</a>
83
+ <a href="Yunhe/Consumer.html#method-c-new">::new</a>
75
84
  &mdash;
76
- <span class="container">Yunhe</span>
85
+ <span class="container">Yunhe::Consumer</span>
77
86
 
78
87
  <li class="method">
79
88
  <a href="Yunhe/Core.html#method-i-consume_with">#consume_with</a>
@@ -62,6 +62,8 @@
62
62
 
63
63
  <li><a href="./README_md.html">README</a>
64
64
 
65
+ <li><a href="./Rakefile.html">Rakefile</a>
66
+
65
67
  <li><a href="./yunhe_gemspec.html">yunhe.gemspec</a>
66
68
 
67
69
  </ul>
@@ -12,10 +12,15 @@ module Yunhe
12
12
  private
13
13
  def job
14
14
  while(true) do
15
- rtn = block.call
16
- queue.enq rtn
15
+ result = block.call
16
+ if result.respond_to? :each
17
+ result.each do |res|
18
+ queue.enq res
19
+ end
20
+ else
21
+ queue.enq result
22
+ end
17
23
  end
18
24
  end
19
-
20
25
  end
21
26
  end
data/lib/yunhe/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yunhe
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yunhe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karloku Sang
@@ -16,12 +16,15 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - ".DS_Store"
19
20
  - ".gitignore"
20
21
  - Gemfile
22
+ - LICENSE.md
21
23
  - README.md
22
24
  - Rakefile
23
25
  - doc/Gemfile.html
24
26
  - doc/README_md.html
27
+ - doc/Rakefile.html
25
28
  - doc/Yunhe.html
26
29
  - doc/Yunhe/Consumer.html
27
30
  - doc/Yunhe/Core.html