Skip to content

Commit bae1761

Browse files
committed
Include intermediate report into final
1 parent addc943 commit bae1761

File tree

1 file changed

+80
-10
lines changed

1 file changed

+80
-10
lines changed

docs-source/ruby-association-final-report.md

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,81 @@
11
# Final report
22

3-
Since the midterm report I have continued working on the project until 8. February as planned.
4-
The remaining half of the time I was focusing on implementing actors
5-
which would precisely match behaviour of Erlang actors.
3+
I started working on the project 6. Dec
4+
and I have continued working on the project until 8. February as planned.
5+
I have worked on following abstractions Throttle, Cancellation, Channel, and ErlangActor.
6+
7+
The code developed during this project is available in
8+
<https://github.com/ruby-concurrency/concurrent-ruby/pull/791>.
9+
The documentation is available at
10+
<http://ruby-concurrency.github.io/concurrent-ruby/master/index.html>.
11+
12+
## Throttle
13+
14+
The Throttle implementation originally had special APIs
15+
to interact with other abstractions like promises.
16+
However it was impractical and the API felt cumbersome.
17+
Therefore the Throttle was finalized with much smaller API surface.
18+
Capacity can be still directly acquired from the Throttle
19+
and then released.
20+
21+
The more common usage of the Throttle is with a proxy executor
22+
`a_throttle.on(Concurrent.global_io_executor)`.
23+
Anything executed on the proxy executor will be throttled and
24+
execute on the given executor. There can be more than one proxy executors.
25+
All abstractions which execute tasks have option to specify executor,
26+
therefore the proxy executor can be injected to any abstraction
27+
throttling its concurrency level.
28+
29+
The abstraction is released in `concurrent-ruby-edge-0.5.0`.
30+
For more details see the documentation
31+
<http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Throttle.html>.
32+
33+
## Cancellation
34+
35+
The Cancellation abstraction provides cooperative cancellation.
36+
37+
The Cancellation abstraction was originally consisting of 2 classes,
38+
during its finalization it was however simplified
39+
to be just a combination of Cancellation object
40+
and an origin which is regular Event or Future,
41+
which improves compose-ability greatly.
42+
Any Event or Future can be easily turned into cancellation.
43+
44+
The standard methods `Thread#raise` of `Thread#kill` available in Ruby
45+
are very dangerous (see linked the blog posts bellow).
46+
Therefore concurrent-ruby provides an alternative.
47+
* <https://jvns.ca/blog/2015/11/27/why-rubys-timeout-is-dangerous-and-thread-dot-raise-is-terrifying/>
48+
* <http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/>
49+
* <http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html>
50+
51+
It provides an object which represents a cancellation event
52+
which can be shared between tasks.
53+
The task has to get the reference to the object
54+
and periodically cooperatively check that it is not cancelled.
55+
56+
The abstraction is released in `concurrent-ruby-edge-0.5.0`.
57+
For more details see the documentation
58+
<http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Cancellation.html>.
59+
60+
## Channel
61+
62+
The channel implementation is inspired by Go.
63+
However this implementation is more flexible.
64+
It has 3 major operations pop, push and select as expected.
65+
Where each operation has 3 variants.
66+
`try_(pop|push|select)` which never blocks and returns always immediately.
67+
`(pop|push|select)` which blocks current thread until it can be done
68+
or until it times out.
69+
`(pop|push|select)_op` which returns Future representing the operation,
70+
which can be easily composed with other asynchronous tasks.
71+
72+
The abstraction is released in `concurrent-ruby-edge-0.5.0`.
73+
For more details see the documentation
74+
<http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Promises/Channel.html>.
75+
76+
## Erlang actors
77+
78+
The actor implementation matches the Erlang's implementation.
679
The Erlang compatible implementation was chosen for two reasons.
780
First reason was to make porting of the Erlang's
881
[OTP](https://learnyousomeerlang.com/what-is-otp) library possible.
@@ -11,10 +84,7 @@ Second reason was
1184
that there is an intersection between Ruby and Elixir programmers.
1285
Elixir runs on Erlang's VM and the programmers are familiar with OTP,
1386
therefore they will be able to reuse their knowledge in Ruby.
14-
15-
## Erlang actors
16-
17-
The actor implementation matches the Erlang's implementation.
87+
1888
Mainly:
1989

2090
* The `exit/1` and `exit/2`
@@ -59,7 +129,7 @@ Erlang method documentation can be found at
59129
The actors can be written in 2 modes. First will require it's own thread,
60130
second will run on a thread pool.
61131
Please see
62-
[Actor types section](http://blog.pitr.ch/concurrent-ruby/master/Concurrent/ErlangActor.html)
132+
[Actor types section](http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ErlangActor.html)
63133
for more details.
64134

65135
### Ordering
@@ -138,7 +208,7 @@ Other actor features like linking, demonitoring, etc. required similar approach.
138208

139209
The abstraction is ready for release.
140210
For more details about usage see the API documentation
141-
<http://blog.pitr.ch/concurrent-ruby/master/Concurrent/ErlangActor.html>.
211+
<http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/ErlangActor.html>.
142212

143213
## Integration
144214

@@ -213,7 +283,7 @@ and the futures are executing on the global thread poll for `:fast` non-blocking
213283
This is of course not an exhaustive list of possible ways how the abstractions can be integrated
214284
but rather few examples to give a feeling what is possible.
215285
Please also see an executable
216-
[example](http://blog.pitr.ch/concurrent-ruby/master/file.medium-example.out.html)
286+
[example](http://ruby-concurrency.github.io/concurrent-ruby/master/file.medium-example.out.html)
217287
using the integrations.
218288

219289
## What was not finished

0 commit comments

Comments
 (0)