Skip to content

Commit 16bc2be

Browse files
committed
Doc update
1 parent 0f4ea95 commit 16bc2be

File tree

12 files changed

+219
-196
lines changed

12 files changed

+219
-196
lines changed

docs-source/channel.out.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ threads
4545
ch.push message: 3
4646
# => #<Concurrent::Promises::Channel:0x000002 capacity taken 0 of 2>
4747
threads.map(&:value)
48-
# => [{:message=>1}, {:message=>2}, {:message=>3}]
48+
# => [{:message=>2}, {:message=>1}, {:message=>3}]
4949
```
5050

5151
### Promises integration
@@ -57,8 +57,8 @@ therefore all operations can be represented as futures.
5757
ch = Concurrent::Promises::Channel.new 2
5858
# => #<Concurrent::Promises::Channel:0x000009 capacity taken 0 of 2>
5959
push_operations = Array.new(3) { |i| ch.push_op message: i }
60-
# => [#<Concurrent::Promises::Future:0x00000a fulfilled>,
61-
# #<Concurrent::Promises::Future:0x00000b fulfilled>,
60+
# => [#<Concurrent::Promises::Future:0x00000a fulfilled with #<Concurrent::Promises::Channel:0x000009 capacity taken 2 of 2>>,
61+
# #<Concurrent::Promises::Future:0x00000b fulfilled with #<Concurrent::Promises::Channel:0x000009 capacity taken 2 of 2>>,
6262
# #<Concurrent::Promises::ResolvableFuture:0x00000c pending>]
6363
```
6464

@@ -78,8 +78,8 @@ push_operations.map(&:value!)
7878
# #<Concurrent::Promises::Channel:0x000009 capacity taken 2 of 2>]
7979

8080
pop_operations = Array.new(3) { |i| ch.pop_op }
81-
# => [#<Concurrent::Promises::ResolvableFuture:0x00000d fulfilled>,
82-
# #<Concurrent::Promises::ResolvableFuture:0x00000e fulfilled>,
81+
# => [#<Concurrent::Promises::ResolvableFuture:0x00000d fulfilled with {:message=>1}>,
82+
# #<Concurrent::Promises::ResolvableFuture:0x00000e fulfilled with {:message=>2}>,
8383
# #<Concurrent::Promises::ResolvableFuture:0x00000f pending>]
8484
ch.push message: 3 # (push|pop) can be freely mixed with (push_o|pop_op)
8585
pop_operations.map(&:value)
@@ -148,7 +148,7 @@ ch.push 2, 0.01 # => true
148148
ch.push 3, 0.01 # => false
149149
ch.pop 0.01 # => 1
150150
ch.pop 0.01 # => 2
151-
ch.pop 0.01 # => [true, nil, nil]
151+
ch.pop 0.01 # => nil
152152
```
153153

154154
### Backpressure
@@ -204,17 +204,17 @@ log
204204
# "producer 0 pushing 2",
205205
# "producer 1 pushing 0",
206206
# "consumer 0 got 0. payload 0 from producer 0",
207+
# "consumer 1 got 0. payload 1 from producer 0",
208+
# "consumer 2 got 0. payload 2 from producer 0",
209+
# "consumer 3 got 0. payload 0 from producer 1",
207210
# "producer 0 pushing 3",
208-
# "consumer 2 got 0. payload 1 from producer 0",
209-
# "consumer 3 got 0. payload 2 from producer 0",
210-
# "consumer 1 got 0. payload 0 from producer 1",
211211
# "producer 1 pushing 1",
212212
# "producer 1 pushing 2",
213-
# "consumer 2 got 1. payload 3 from producer 0",
214-
# "consumer 3 got 1. payload 1 from producer 1",
215-
# "consumer 1 got 1. payload 2 from producer 1",
213+
# "consumer 0 got 1. payload 3 from producer 0",
214+
# "consumer 1 got 1. payload 1 from producer 1",
215+
# "consumer 2 got 1. payload 2 from producer 1",
216216
# "producer 1 pushing 3",
217-
# "consumer 0 got 1. payload 3 from producer 1"]
217+
# "consumer 3 got 1. payload 3 from producer 1"]
218218
```
219219

220220
The producers are much faster than consumers
@@ -269,20 +269,20 @@ consumers.map(&:value!) # => [:done, :done, :done, :done]
269269
log
270270
# => ["producer 0 pushing 0",
271271
# "producer 1 pushing 0",
272-
# "consumer 0 got 0. payload 0 from producer 0",
273272
# "producer 0 pushing 1",
274273
# "producer 1 pushing 1",
275-
# "consumer 2 got 0. payload 0 from producer 1",
276-
# "consumer 3 got 0. payload 1 from producer 0",
274+
# "consumer 0 got 0. payload 0 from producer 0",
275+
# "consumer 1 got 0. payload 0 from producer 1",
276+
# "consumer 2 got 0. payload 1 from producer 0",
277277
# "producer 0 pushing 2",
278-
# "producer 0 pushing 3",
279-
# "consumer 1 got 0. payload 1 from producer 1",
278+
# "consumer 3 got 0. payload 1 from producer 1",
280279
# "producer 1 pushing 2",
280+
# "producer 0 pushing 3",
281281
# "producer 1 pushing 3",
282+
# "consumer 3 got 1. payload 3 from producer 1",
282283
# "consumer 0 got 1. payload 2 from producer 0",
283-
# "consumer 3 got 1. payload 3 from producer 0",
284-
# "consumer 2 got 1. payload 2 from producer 1",
285-
# "consumer 1 got 1. payload 3 from producer 1"]
284+
# "consumer 1 got 1. payload 2 from producer 1",
285+
# "consumer 2 got 1. payload 3 from producer 0"]
286286
```
287287

288288
### Synchronization of workers by passing a value
@@ -309,5 +309,5 @@ thread.value # => :v1
309309
# the push operation resolves as a pairing pop is called
310310
channel.pop # => :v2
311311
push
312-
# => #<Concurrent::Promises::ResolvableFuture:0x000023 fulfilled>
312+
# => #<Concurrent::Promises::ResolvableFuture:0x000023 fulfilled with #<Concurrent::Promises::Channel:0x000021 capacity taken 0 of 0>>
313313
```

docs-source/promises.out.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ Instead, it can be created directly as already-resolved:
218218

219219
```ruby
220220
Concurrent::Promises.fulfilled_future(:value)
221-
# => #<Concurrent::Promises::Future:0x000008 fulfilled>
221+
# => #<Concurrent::Promises::Future:0x000008 fulfilled with :value>
222222
Concurrent::Promises.rejected_future(StandardError.new('Ups'))
223-
# => #<Concurrent::Promises::Future:0x000009 rejected>
223+
# => #<Concurrent::Promises::Future:0x000009 rejected with #<StandardError: Ups>>
224224
Concurrent::Promises.resolved_future(true, :value, nil)
225-
# => #<Concurrent::Promises::Future:0x00000a fulfilled>
225+
# => #<Concurrent::Promises::Future:0x00000a fulfilled with :value>
226226
Concurrent::Promises.resolved_future(false, nil, StandardError.new('Ups'))
227-
# => #<Concurrent::Promises::Future:0x00000b rejected>
227+
# => #<Concurrent::Promises::Future:0x00000b rejected with #<StandardError: Ups>>
228228
```
229229

230230
## Chaining
@@ -388,7 +388,7 @@ Zip is rejected if any of the zipped futures is.
388388
rejected_zip = Concurrent::Promises.zip(
389389
Concurrent::Promises.fulfilled_future(1),
390390
Concurrent::Promises.rejected_future(StandardError.new('Ups')))
391-
# => #<Concurrent::Promises::Future:0x000011 rejected>
391+
# => #<Concurrent::Promises::Future:0x000011 rejected with [nil, #<StandardError: Ups>]>
392392
rejected_zip.result
393393
# => [false, [1, nil], [nil, #<StandardError: Ups>]]
394394
rejected_zip.
@@ -531,7 +531,7 @@ The thread will be blocked until the future is resolved
531531
```ruby
532532
thread = Thread.new { future.value }
533533
future.fulfill 1
534-
# => #<Concurrent::Promises::ResolvableFuture:0x000015 fulfilled>
534+
# => #<Concurrent::Promises::ResolvableFuture:0x000015 fulfilled with 1>
535535
thread.value # => 1
536536
```
537537

@@ -667,14 +667,14 @@ more messages.
667667

668668
```ruby
669669
pushes = 3.times.map { |i| ch1.push_op i }
670-
# => [#<Concurrent::Promises::Future:0x00001b fulfilled>,
671-
# #<Concurrent::Promises::Future:0x00001c fulfilled>,
670+
# => [#<Concurrent::Promises::Future:0x00001b fulfilled with #<Concurrent::Promises::Channel:0x00001a capacity taken 2 of 2>>,
671+
# #<Concurrent::Promises::Future:0x00001c fulfilled with #<Concurrent::Promises::Channel:0x00001a capacity taken 2 of 2>>,
672672
# #<Concurrent::Promises::ResolvableFuture:0x00001d pending>]
673673
ch1.pop_op.value! # => 0
674674
pushes
675-
# => [#<Concurrent::Promises::Future:0x00001b fulfilled>,
676-
# #<Concurrent::Promises::Future:0x00001c fulfilled>,
677-
# #<Concurrent::Promises::ResolvableFuture:0x00001d fulfilled>]
675+
# => [#<Concurrent::Promises::Future:0x00001b fulfilled with #<Concurrent::Promises::Channel:0x00001a capacity taken 2 of 2>>,
676+
# #<Concurrent::Promises::Future:0x00001c fulfilled with #<Concurrent::Promises::Channel:0x00001a capacity taken 2 of 2>>,
677+
# #<Concurrent::Promises::ResolvableFuture:0x00001d fulfilled with #<Concurrent::Promises::Channel:0x00001a capacity taken 2 of 2>>]
678678
```
679679

680680
A selection over channels can be created with the `.select_channel` factory method. It
@@ -685,7 +685,7 @@ returns a pair to be able to find out which channel had the message available.
685685
ch2 = Concurrent::Promises::Channel.new 2
686686
# => #<Concurrent::Promises::Channel:0x00001e capacity taken 0 of 2>
687687
result = Concurrent::Promises::Channel.select_op([ch1, ch2])
688-
# => #<Concurrent::Promises::ResolvableFuture:0x00001f fulfilled>
688+
# => #<Concurrent::Promises::ResolvableFuture:0x00001f fulfilled with [#<Concurrent::Promises::Channel:0x00001a capacity taken 1 of 2>, 1]>
689689
result.value!
690690
# => [#<Concurrent::Promises::Channel:0x00001a capacity taken 1 of 2>, 1]
691691

@@ -780,7 +780,7 @@ end
780780
# => #<Proc:[email protected]:662 (lambda)>
781781

782782
Concurrent::Promises.future(actor, 0, &produce).run.wait!
783-
# => #<Concurrent::Promises::Future:0x00002e fulfilled>
783+
# => #<Concurrent::Promises::Future:0x00002e fulfilled with #<Concurrent::ProcessingActor:0x00002a @Mailbox=#<Concurrent::Promises::Channel:0x00002b capacity taken 2 of 2>, @Terminated=#<Concurrent::Promises::ResolvableFuture:0x00002c pending> termination:pending>>
784784

785785
actor.termination.value! # => 45
786786
```
@@ -1088,12 +1088,12 @@ Let it run for a while, then cancel it, and ensure that the runs were all fulfil
10881088
origin.resolve
10891089
# => #<Concurrent::Promises::ResolvableEvent:0x000044 resolved>
10901090
query_processes.map(&:wait!)
1091-
# => [#<Concurrent::Promises::Future:0x00003f fulfilled>,
1092-
# #<Concurrent::Promises::Future:0x000040 fulfilled>,
1093-
# #<Concurrent::Promises::Future:0x000041 fulfilled>]
1091+
# => [#<Concurrent::Promises::Future:0x00003f fulfilled with nil>,
1092+
# #<Concurrent::Promises::Future:0x000040 fulfilled with nil>,
1093+
# #<Concurrent::Promises::Future:0x000041 fulfilled with nil>]
10941094
word_counter_processes.map(&:wait!)
1095-
# => [#<Concurrent::Promises::Future:0x000042 fulfilled>,
1096-
# #<Concurrent::Promises::Future:0x000043 fulfilled>]
1095+
# => [#<Concurrent::Promises::Future:0x000042 fulfilled with nil>,
1096+
# #<Concurrent::Promises::Future:0x000043 fulfilled with nil>]
10971097
words # => [7, 7, 7, 7]
10981098
```
10991099

docs/master/Concurrent/Promises.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ <h3 class="signature " id="rejected_future-class_method">
22662266
<span class='name'>reason</span>
22672267

22682268

2269-
<span class='type'>(<tt>Exception</tt>)</span>
2269+
<span class='type'>(<tt>Object</tt>)</span>
22702270

22712271

22722272

@@ -2630,7 +2630,7 @@ <h3 class="signature " id="resolved_future-class_method">
26302630
<span class='name'>reason</span>
26312631

26322632

2633-
<span class='type'>(<tt>Exception</tt>)</span>
2633+
<span class='type'>(<tt>Object</tt>)</span>
26342634

26352635

26362636

docs/master/Concurrent/Promises/AbstractEventFuture.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ <h3 class="signature " id="chain_on-instance_method">
667667
<span class='name'>reason</span>
668668

669669

670-
<span class='type'>(<tt>Exception</tt>)</span>
670+
<span class='type'>(<tt>Object</tt>)</span>
671671

672672

673673

@@ -1143,7 +1143,7 @@ <h3 class="signature " id="on_resolution!-instance_method">
11431143
<span class='name'>reason</span>
11441144

11451145

1146-
<span class='type'>(<tt>Exception</tt>)</span>
1146+
<span class='type'>(<tt>Object</tt>)</span>
11471147

11481148

11491149

@@ -1343,7 +1343,7 @@ <h3 class="signature " id="on_resolution_using-instance_method">
13431343
<span class='name'>reason</span>
13441344

13451345

1346-
<span class='type'>(<tt>Exception</tt>)</span>
1346+
<span class='type'>(<tt>Object</tt>)</span>
13471347

13481348

13491349

0 commit comments

Comments
 (0)