Skip to content

Commit 7b6ddd1

Browse files
authored
Merge pull request #783 from ruby-concurrency/minor
Minor
2 parents dee4f1d + ad6555c commit 7b6ddd1

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

Rakefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ edge_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-edge.
1818

1919
require 'rake/javaextensiontask'
2020

21-
JRUBY_JAR_PATH = '/usr/local/opt/rbenv/versions/jruby-9.1.17.0/lib/jruby.jar'
22-
2321
class ConcurrentRubyJavaExtensionTask < Rake::JavaExtensionTask
2422
def java_classpath_arg(*args)
2523
jruby_cpath = nil
@@ -42,10 +40,15 @@ class ConcurrentRubyJavaExtensionTask < Rake::JavaExtensionTask
4240
end
4341

4442
unless jruby_cpath
45-
jruby_cpath = JRUBY_JAR_PATH
46-
raise "#{jruby_cpath} does not exist" unless File.exist? jruby_cpath
43+
jruby_home = ENV['JRUBY_HOME']
44+
if jruby_home
45+
candidate = File.join(jruby_home, 'lib', 'jruby.jar')
46+
jruby_cpath = candidate if File.exist? candidate
47+
end
4748
end
4849

50+
raise "jruby.jar path not found" unless jruby_cpath
51+
4952
jruby_cpath += File::PATH_SEPARATOR + args.join(File::PATH_SEPARATOR) unless args.empty?
5053
jruby_cpath ? "-cp \"#{jruby_cpath}\"" : ""
5154
end
@@ -74,7 +77,9 @@ namespace :repackage do
7477
desc '* with Windows fat distributions'
7578
task :all do
7679
Dir.chdir(__dir__) do
80+
# store gems in vendor cache for docker
7781
sh 'bundle package'
82+
7883
# needed only if the jar is built outside of docker
7984
Rake::Task['lib/concurrent/concurrent_ruby.jar'].invoke
8085
RakeCompilerDock.exec 'support/cross_building.sh'

docs-source/promises.in.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ future = Concurrent::Promises.future(0.1) do |duration|
6161
sleep duration
6262
:result
6363
end
64+
future.value
6465
```
6566

6667
Asks if the future is resolved, here it will be still in the middle of the

docs-source/promises.out.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ future = Concurrent::Promises.future(0.1) do |duration|
9595
:result
9696
end
9797
# => #<Concurrent::Promises::Future:0x000005 pending>
98+
future.value # => :result
9899
```
99100

100101
Asks if the future is resolved, here it will be still in the middle of the
101102
sleep call.
102103

103104
```ruby
104-
future.resolved? # => false
105+
future.resolved? # => true
105106
```
106107

107108
Retrieving the value will block until the future is **resolved**.
@@ -264,7 +265,7 @@ do_stuff arg }`) is **required**. Both of the following bad examples may break:
264265
```ruby
265266
arg = 1 # => 1
266267
Thread.new { do_stuff arg }
267-
# => #<Thread:[email protected]:203 run>
268+
# => #<Thread:[email protected]:204 run>
268269
Concurrent::Promises.future { do_stuff arg }
269270
# => #<Concurrent::Promises::Future:0x00000d pending>
270271
```
@@ -274,7 +275,7 @@ Correct:
274275
```ruby
275276
arg = 1 # => 1
276277
Thread.new(arg) { |arg| do_stuff arg }
277-
# => #<Thread:[email protected]:211 run>
278+
# => #<Thread:[email protected]:212 run>
278279
Concurrent::Promises.future(arg) { |arg| do_stuff arg }
279280
# => #<Concurrent::Promises::Future:0x00000f pending>
280281
```
@@ -593,7 +594,7 @@ and `:io` for long-running and blocking tasks.
593594
```ruby
594595
Concurrent::Promises.future_on(:fast) { 2 }.
595596
then_on(:io) { File.read __FILE__ }.
596-
value.size # => 27117
597+
value.size # => 27130
597598
```
598599

599600
## Run (simulated process)
@@ -607,7 +608,7 @@ count = lambda do |v|
607608
v += 1
608609
v < 5 ? Concurrent::Promises.future_on(:fast, v, &count) : v
609610
end
610-
# => #<Proc:[email protected]:520 (lambda)>
611+
# => #<Proc:[email protected]:521 (lambda)>
611612
400.times.
612613
map { Concurrent::Promises.future_on(:fast, 0, &count).run.value! }.
613614
all? { |v| v == 5 } # => true

docs/master/file.CHANGELOG.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959

6060
<div id="content"><div id='filecontents'><h2>Current</h2>
6161

62+
<ul>
63+
<li>(#776) Fix NameError on defining a struct with a name which is already taken in an ancestor</li>
64+
</ul>
65+
6266
<h2>Release v1.1.3 (7 Nov 2018)</h2>
6367

6468
<ul>

docs/master/file.promises.out.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ <h2>Asynchronous task</h2>
148148
<span class='symbol'>:result</span>
149149
<span class='kw'>end</span>
150150
<span class='comment'># =&gt; #&lt;Concurrent::Promises::Future:0x000005 pending&gt;
151+
</span><span class='id identifier rubyid_future'>future</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='comment'># =&gt; :result
151152
</span></code></pre>
152153

153154
<p>Asks if the future is resolved, here it will be still in the middle of the
154155
sleep call.</p>
155156

156-
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_future'>future</span><span class='period'>.</span><span class='id identifier rubyid_resolved?'>resolved?</span> <span class='comment'># =&gt; false
157+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_future'>future</span><span class='period'>.</span><span class='id identifier rubyid_resolved?'>resolved?</span> <span class='comment'># =&gt; true
157158
</span></code></pre>
158159

159160
<p>Retrieving the value will block until the future is <strong>resolved</strong>.</p>
@@ -303,7 +304,7 @@ <h2>Chaining</h2>
303304

304305
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_arg'>arg</span> <span class='op'>=</span> <span class='int'>1</span> <span class='comment'># =&gt; 1
305306
</span><span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_do_stuff'>do_stuff</span> <span class='id identifier rubyid_arg'>arg</span> <span class='rbrace'>}</span>
306-
<span class='comment'># =&gt; #&lt;Thread:[email protected]:203 run&gt;
307+
<span class='comment'># =&gt; #&lt;Thread:[email protected]:204 run&gt;
307308
</span><span class='const'><span class='object_link'><a href="Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Concurrent/Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future'><span class='object_link'><a href="Concurrent/Promises/FactoryMethods.html#future-instance_method" title="Concurrent::Promises::FactoryMethods#future (method)">future</a></span></span> <span class='lbrace'>{</span> <span class='id identifier rubyid_do_stuff'>do_stuff</span> <span class='id identifier rubyid_arg'>arg</span> <span class='rbrace'>}</span>
308309
<span class='comment'># =&gt; #&lt;Concurrent::Promises::Future:0x00000d pending&gt;
309310
</span></code></pre>
@@ -312,7 +313,7 @@ <h2>Chaining</h2>
312313

313314
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_arg'>arg</span> <span class='op'>=</span> <span class='int'>1</span> <span class='comment'># =&gt; 1
314315
</span><span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span> <span class='id identifier rubyid_do_stuff'>do_stuff</span> <span class='id identifier rubyid_arg'>arg</span> <span class='rbrace'>}</span>
315-
<span class='comment'># =&gt; #&lt;Thread:[email protected]:211 run&gt;
316+
<span class='comment'># =&gt; #&lt;Thread:[email protected]:212 run&gt;
316317
</span><span class='const'><span class='object_link'><a href="Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Concurrent/Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future'><span class='object_link'><a href="Concurrent/Promises/FactoryMethods.html#future-instance_method" title="Concurrent::Promises::FactoryMethods#future (method)">future</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>|</span> <span class='id identifier rubyid_do_stuff'>do_stuff</span> <span class='id identifier rubyid_arg'>arg</span> <span class='rbrace'>}</span>
317318
<span class='comment'># =&gt; #&lt;Concurrent::Promises::Future:0x00000f pending&gt;
318319
</span></code></pre>
@@ -610,7 +611,7 @@ <h2>Using executors</h2>
610611

611612
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Concurrent/Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future_on'><span class='object_link'><a href="Concurrent/Promises/FactoryMethods.html#future_on-instance_method" title="Concurrent::Promises::FactoryMethods#future_on (method)">future_on</a></span></span><span class='lparen'>(</span><span class='symbol'>:fast</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='int'>2</span> <span class='rbrace'>}</span><span class='period'>.</span>
612613
<span class='id identifier rubyid_then_on'>then_on</span><span class='lparen'>(</span><span class='symbol'>:io</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span> <span class='kw'>__FILE__</span> <span class='rbrace'>}</span><span class='period'>.</span>
613-
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='comment'># =&gt; 27117
614+
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='comment'># =&gt; 27130
614615
</span></code></pre>
615616

616617
<h2>Run (simulated process)</h2>
@@ -623,7 +624,7 @@ <h2>Run (simulated process)</h2>
623624
<span class='id identifier rubyid_v'>v</span> <span class='op'>+=</span> <span class='int'>1</span>
624625
<span class='id identifier rubyid_v'>v</span> <span class='op'>&lt;</span> <span class='int'>5</span> <span class='op'>?</span> <span class='const'><span class='object_link'><a href="Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Concurrent/Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future_on'><span class='object_link'><a href="Concurrent/Promises/FactoryMethods.html#future_on-instance_method" title="Concurrent::Promises::FactoryMethods#future_on (method)">future_on</a></span></span><span class='lparen'>(</span><span class='symbol'>:fast</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_count'>count</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_v'>v</span>
625626
<span class='kw'>end</span>
626-
<span class='comment'># =&gt; #&lt;Proc:[email protected]:520 (lambda)&gt;
627+
<span class='comment'># =&gt; #&lt;Proc:[email protected]:521 (lambda)&gt;
627628
</span><span class='int'>400</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span><span class='period'>.</span>
628629
<span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='const'><span class='object_link'><a href="Concurrent.html" title="Concurrent (module)">Concurrent</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Concurrent/Promises.html" title="Concurrent::Promises (module)">Promises</a></span></span><span class='period'>.</span><span class='id identifier rubyid_future_on'><span class='object_link'><a href="Concurrent/Promises/FactoryMethods.html#future_on-instance_method" title="Concurrent::Promises::FactoryMethods#future_on (method)">future_on</a></span></span><span class='lparen'>(</span><span class='symbol'>:fast</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_count'>count</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_run'><span class='object_link'><a href="Concurrent/Promises/Future.html#run-instance_method" title="Concurrent::Promises::Future#run (method)">run</a></span></span><span class='period'>.</span><span class='id identifier rubyid_value!'><span class='object_link'><a href="Concurrent/Promises/Future.html#value!-instance_method" title="Concurrent::Promises::Future#value! (method)">value!</a></span></span> <span class='rbrace'>}</span><span class='period'>.</span>
629630
<span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span> <span class='op'>==</span> <span class='int'>5</span> <span class='rbrace'>}</span> <span class='comment'># =&gt; true

0 commit comments

Comments
 (0)