polyphony 0.41 → 0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +5 -5
- data/Rakefile +1 -1
- data/TODO.md +19 -9
- data/docs/_config.yml +56 -7
- data/docs/_sass/custom/custom.scss +0 -30
- data/docs/_sass/overrides.scss +0 -46
- data/docs/{user-guide → _user-guide}/all-about-timers.md +0 -0
- data/docs/_user-guide/index.md +9 -0
- data/docs/{user-guide → _user-guide}/web-server.md +0 -0
- data/docs/api-reference/index.md +9 -0
- data/docs/api-reference/polyphony-process.md +1 -1
- data/docs/api-reference/thread.md +1 -1
- data/docs/faq.md +21 -11
- data/docs/getting-started/index.md +10 -0
- data/docs/getting-started/installing.md +2 -6
- data/docs/getting-started/overview.md +507 -0
- data/docs/getting-started/tutorial.md +27 -19
- data/docs/index.md +1 -1
- data/docs/main-concepts/concurrency.md +0 -5
- data/docs/main-concepts/design-principles.md +2 -12
- data/docs/main-concepts/index.md +9 -0
- data/examples/core/01-spinning-up-fibers.rb +1 -0
- data/examples/core/03-interrupting.rb +4 -1
- data/examples/core/04-handling-signals.rb +19 -0
- data/examples/performance/thread-vs-fiber/polyphony_server.rb +6 -18
- data/examples/performance/thread-vs-fiber/polyphony_server_read_loop.rb +58 -0
- data/examples/performance/xx-array.rb +11 -0
- data/examples/performance/xx-fiber-switch.rb +9 -0
- data/examples/performance/xx-snooze.rb +15 -0
- data/ext/polyphony/fiber.c +0 -3
- data/ext/polyphony/libev_agent.c +234 -19
- data/ext/polyphony/libev_queue.c +3 -1
- data/ext/polyphony/polyphony.c +0 -10
- data/ext/polyphony/polyphony.h +6 -6
- data/ext/polyphony/thread.c +8 -36
- data/lib/polyphony.rb +5 -2
- data/lib/polyphony/core/channel.rb +2 -2
- data/lib/polyphony/core/global_api.rb +2 -2
- data/lib/polyphony/core/resource_pool.rb +2 -2
- data/lib/polyphony/extensions/core.rb +2 -3
- data/lib/polyphony/version.rb +1 -1
- data/polyphony.gemspec +1 -1
- data/test/test_agent.rb +49 -2
- metadata +16 -20
- data/docs/_includes/head.html +0 -40
- data/docs/_includes/nav.html +0 -51
- data/docs/_includes/prevnext.html +0 -17
- data/docs/_layouts/default.html +0 -106
- data/docs/api-reference.md +0 -11
- data/docs/api-reference/gyro-async.md +0 -57
- data/docs/api-reference/gyro-child.md +0 -29
- data/docs/api-reference/gyro-queue.md +0 -44
- data/docs/api-reference/gyro-timer.md +0 -51
- data/docs/api-reference/gyro.md +0 -25
- data/docs/getting-started.md +0 -10
- data/docs/main-concepts.md +0 -10
- data/docs/user-guide.md +0 -10
- data/examples/core/forever_sleep.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e284cae2a5eb2332bc8671090412bbe0cf7d57dbc163d68ba387f4d9635a8adf
|
4
|
+
data.tar.gz: 58eba5a2607df83c7471b1a6b72cc350aa468e9a562e3d1e8f7451eaae12d068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10b7bcf9240ea8f7355c75d025bd6c5e1bd00c86e7985f71440091cc149c629279b16eaf1c863d85de29e278739926b499625c77238db8eb803aa235395771a4
|
7
|
+
data.tar.gz: 9001df441fdc058a3234bca05f6cca55d3a27edcf0b5b0d126a9c371d37bd0ffecc4d13d8f13c614d9b7182630f94d54481035f6d83fb044aebdf3238f83b03a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 0.42 2020-07-03
|
2
|
+
|
3
|
+
* Improve documentation
|
4
|
+
* Fix backtrace on SIGINT
|
5
|
+
* Implement LibevAgent#accept_loop, #read_loop
|
6
|
+
* Move ref counting from thread to agent
|
7
|
+
* Short circuit switchpoint if continuing with the same fiber
|
8
|
+
* Always do a switchpoint in #read, #write, #accept
|
9
|
+
|
1
10
|
## 0.41 2020-06-27
|
2
11
|
|
3
12
|
* Introduce System Agent design, remove all `Gyro` classes
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
polyphony (0.
|
4
|
+
polyphony (0.42)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -51,10 +51,10 @@ GEM
|
|
51
51
|
jekyll-watch (2.2.1)
|
52
52
|
listen (~> 3.0)
|
53
53
|
json (2.3.0)
|
54
|
-
just-the-docs (0.
|
55
|
-
jekyll (
|
54
|
+
just-the-docs (0.3.0)
|
55
|
+
jekyll (>= 3.8.5)
|
56
56
|
jekyll-seo-tag (~> 2.0)
|
57
|
-
rake (
|
57
|
+
rake (>= 12.3.1, < 13.1.0)
|
58
58
|
kramdown (1.17.0)
|
59
59
|
liquid (4.0.3)
|
60
60
|
listen (3.2.1)
|
@@ -126,7 +126,7 @@ DEPENDENCIES
|
|
126
126
|
jekyll (~> 3.8.6)
|
127
127
|
jekyll-remote-theme (~> 0.4.1)
|
128
128
|
jekyll-seo-tag (~> 2.6.1)
|
129
|
-
just-the-docs (~> 0.
|
129
|
+
just-the-docs (~> 0.3.0)
|
130
130
|
localhost (= 1.1.4)
|
131
131
|
minitest (= 5.13.0)
|
132
132
|
minitest-reporters (= 1.4.2)
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ task :stress_test do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
task :docs do
|
23
|
-
exec 'RUBYOPT=-W0 jekyll serve -s docs'
|
23
|
+
exec 'RUBYOPT=-W0 jekyll serve -s docs -H ec2-35-158-110-38.eu-central-1.compute.amazonaws.com'
|
24
24
|
end
|
25
25
|
|
26
26
|
CLEAN.include "**/*.o", "**/*.so", "**/*.bundle", "**/*.jar", "pkg", "tmp"
|
data/TODO.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
## 0.42
|
1
|
+
## 0.42
|
2
2
|
|
3
|
-
-
|
4
|
-
|
5
|
-
|
3
|
+
- Reimplement ResourcePool, Channel, Mutex using LibevQueue
|
4
|
+
-- Add `Fiber#schedule_with_priority` method, aliased by `Fiber#wakeup`
|
5
|
+
- Implement agent interface is virtual function table
|
6
|
+
- Implement proxy agent for plugging in a user-provided agent class
|
6
7
|
|
8
|
+
## 0.43
|
7
9
|
- Debugging
|
8
10
|
- Eat your own dogfood: need a good tool to check what's going on when some
|
9
11
|
test fails
|
@@ -116,7 +118,10 @@
|
|
116
118
|
- explain difference between `sleep` and `suspend`
|
117
119
|
- discuss using `snooze` for ensuring responsiveness when executing CPU-bound work
|
118
120
|
|
119
|
-
|
121
|
+
|
122
|
+
## 0.44
|
123
|
+
|
124
|
+
### Some more API work, more docs
|
120
125
|
|
121
126
|
- sintra app with database access (postgresql)
|
122
127
|
|
@@ -126,11 +131,16 @@
|
|
126
131
|
- test performance
|
127
132
|
- proceed from there
|
128
133
|
|
129
|
-
|
134
|
+
|
135
|
+
## 0.45
|
136
|
+
|
137
|
+
### Sinatra / Sidekiq
|
130
138
|
|
131
139
|
- Pull out redis/postgres code, put into new `polyphony-xxx` gems
|
132
140
|
|
133
|
-
## 0.46
|
141
|
+
## 0.46
|
142
|
+
|
143
|
+
### Testing && Docs
|
134
144
|
|
135
145
|
- More tests
|
136
146
|
- Implement some basic stuff missing:
|
@@ -140,9 +150,9 @@
|
|
140
150
|
- `IO.foreach`
|
141
151
|
- `Process.waitpid`
|
142
152
|
|
143
|
-
## 0.47
|
153
|
+
## 0.47
|
144
154
|
|
145
|
-
|
155
|
+
### Real IO#gets and IO#read
|
146
156
|
|
147
157
|
## 0.48 DNS
|
148
158
|
|
data/docs/_config.yml
CHANGED
@@ -1,15 +1,64 @@
|
|
1
1
|
title: "Polyphony"
|
2
|
+
description: Fine-grained concurrency for Ruby
|
2
3
|
|
4
|
+
plugins:
|
5
|
+
- jekyll-remote-theme
|
6
|
+
|
7
|
+
permalink: pretty
|
3
8
|
remote_theme: pmarsceill/just-the-docs
|
4
|
-
color_scheme:
|
9
|
+
color_scheme: light
|
5
10
|
|
6
11
|
search_enabled: true
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
search:
|
13
|
+
# Split pages into sections that can be searched individually
|
14
|
+
# Supports 1 - 6, default: 2
|
15
|
+
heading_level: 2
|
16
|
+
# Maximum amount of previews per search result
|
17
|
+
# Default: 3
|
18
|
+
previews: 3
|
19
|
+
# Maximum amount of words to display before a matched word in the preview
|
20
|
+
# Default: 5
|
21
|
+
preview_words_before: 5
|
22
|
+
# Maximum amount of words to display after a matched word in the preview
|
23
|
+
# Default: 10
|
24
|
+
preview_words_after: 10
|
25
|
+
# Set the search token separator
|
26
|
+
# Default: /[\s\-/]+/
|
27
|
+
# Example: enable support for hyphenated search words
|
28
|
+
tokenizer_separator: /[\s/]+/
|
29
|
+
# Display the relative url in search results
|
30
|
+
# Supports true (default) or false
|
31
|
+
rel_url: true
|
32
|
+
# Enable or disable the search button that appears in the bottom right corner of every page
|
33
|
+
# Supports true or false (default)
|
34
|
+
button: false
|
12
35
|
|
13
36
|
aux_links:
|
14
37
|
"Polyphony on GitHub":
|
15
|
-
- "//github.com/digital-fabric/polyphony"
|
38
|
+
- "//github.com/digital-fabric/polyphony"
|
39
|
+
|
40
|
+
# Makes Aux links open in a new tab. Default is false
|
41
|
+
aux_links_new_tab: false
|
42
|
+
|
43
|
+
# Enable or disable heading anchors
|
44
|
+
heading_anchors: true
|
45
|
+
|
46
|
+
back_to_top: true
|
47
|
+
back_to_top_text: "Back to top"
|
48
|
+
|
49
|
+
footer_content: "Copyright © 2018-2020 Sharon Rosner. Distributed by an <a href=\"https://github.com/digital-fabric/polyphony/tree/master/LICENSE.txt\">MIT license.</a>"
|
50
|
+
|
51
|
+
# Footer "Edit this page on GitHub" link text
|
52
|
+
gh_edit_link: true # show or hide edit this page link
|
53
|
+
gh_edit_link_text: "Edit this page on GitHub"
|
54
|
+
gh_edit_repository: "https://github.com/digital-fabric/polyphony" # the github URL for your repo
|
55
|
+
gh_edit_branch: "master" # the branch that your docs is served from
|
56
|
+
gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately
|
57
|
+
|
58
|
+
compress_html:
|
59
|
+
clippings: all
|
60
|
+
comments: all
|
61
|
+
endings: all
|
62
|
+
startings: []
|
63
|
+
blanklines: false
|
64
|
+
profile: false
|
@@ -1,30 +0,0 @@
|
|
1
|
-
$nav-child-link-color: #9d9b9e;
|
2
|
-
$link-color: $blue-000;
|
3
|
-
|
4
|
-
.img-figure {
|
5
|
-
text-align: center;
|
6
|
-
}
|
7
|
-
|
8
|
-
#prevnext {
|
9
|
-
padding-top: 1em;
|
10
|
-
}
|
11
|
-
|
12
|
-
#prevnext span {
|
13
|
-
}
|
14
|
-
|
15
|
-
#prevnext span.prev {
|
16
|
-
float: left;
|
17
|
-
padding-right: 4em;
|
18
|
-
}
|
19
|
-
|
20
|
-
#prevnext span.next {
|
21
|
-
float: right;
|
22
|
-
}
|
23
|
-
|
24
|
-
#prevnext span.clear {
|
25
|
-
clear: both;
|
26
|
-
}
|
27
|
-
|
28
|
-
.h-align-center {
|
29
|
-
text-align: center;
|
30
|
-
}
|
data/docs/_sass/overrides.scss
CHANGED
@@ -1,46 +0,0 @@
|
|
1
|
-
.navigation-list-item.section-title {
|
2
|
-
padding-top: 0.75em;
|
3
|
-
padding-bottom: 0.75em;
|
4
|
-
}
|
5
|
-
|
6
|
-
span.section-title {
|
7
|
-
text-transform: uppercase;
|
8
|
-
font-weight: bold;
|
9
|
-
color: #888;
|
10
|
-
}
|
11
|
-
|
12
|
-
.navigation-list-item .navigation-list-child-list {
|
13
|
-
display: block;
|
14
|
-
}
|
15
|
-
|
16
|
-
.navigation-list-child-list {
|
17
|
-
padding-left: 0;
|
18
|
-
|
19
|
-
.navigation-list-item {
|
20
|
-
position: relative;
|
21
|
-
|
22
|
-
&::before {
|
23
|
-
position: absolute;
|
24
|
-
margin-top: 0.3em;
|
25
|
-
margin-left: -0.8em;
|
26
|
-
color: rgba($body-text-color, 0.3);
|
27
|
-
content: "";
|
28
|
-
}
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
a.navigation-list-link {
|
33
|
-
margin-left: 4px;
|
34
|
-
padding-left: 4px;
|
35
|
-
color: $nav-child-link-color;
|
36
|
-
font-weight: 600;
|
37
|
-
}
|
38
|
-
|
39
|
-
a.navigation-list-link.active {
|
40
|
-
margin-left: 0;
|
41
|
-
border-left: 4px #6ae solid;
|
42
|
-
}
|
43
|
-
|
44
|
-
a.navigation-list-link:hover {
|
45
|
-
color: $link-color;
|
46
|
-
}
|
File without changes
|
File without changes
|
@@ -23,6 +23,6 @@ shell command. If a block is given, the child process is started using
|
|
23
23
|
[`Polyphony#fork`](../polyphony/#fork-block---pid).
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
Polyphony::Process.watch('echo "Hello World"; sleep 1')
|
26
|
+
spin { Polyphony::Process.watch('echo "Hello World"; sleep 1') }
|
27
27
|
supervise(restart: :always)
|
28
28
|
```
|
@@ -12,7 +12,7 @@ Polyphony enhances the core `Thread` class with APIs for switching and
|
|
12
12
|
scheduling fibers, and reimplements some of its APIs such as `Thread#raise`
|
13
13
|
using fibers which, incidentally, make it safe.
|
14
14
|
|
15
|
-
Each thread has its own run queue and its own
|
15
|
+
Each thread has its own run queue and its own system agent. While running
|
16
16
|
multiple threads does not result in true parallelism in MRI Ruby, sometimes
|
17
17
|
multithreading is inevitable, for instance when using third-party gems that
|
18
18
|
spawn threads, or when calling blocking APIs that are not fiber-aware.
|
data/docs/faq.md
CHANGED
@@ -3,9 +3,19 @@ layout: page
|
|
3
3
|
title: Frequently Asked Questions
|
4
4
|
nav_order: 100
|
5
5
|
---
|
6
|
+
|
6
7
|
# Frequently Asked Questions
|
8
|
+
{: .no_toc }
|
9
|
+
|
10
|
+
## Table of contents
|
11
|
+
{: .no_toc .text-delta }
|
12
|
+
|
13
|
+
- TOC
|
14
|
+
{:toc}
|
15
|
+
|
16
|
+
---
|
7
17
|
|
8
|
-
|
18
|
+
## Why not just use callbacks instead of fibers?
|
9
19
|
|
10
20
|
It is true that reactor engines such as libev use callbacks to handle events.
|
11
21
|
There's also programming platforms such as [node.js](https://nodejs.org/) that
|
@@ -87,7 +97,7 @@ In conclusion:
|
|
87
97
|
* Callbacks often lead to code bloat.
|
88
98
|
* Callbacks are harder to debug.
|
89
99
|
|
90
|
-
|
100
|
+
## If callbacks suck, why not use promises?
|
91
101
|
|
92
102
|
Promises have gained a lot of traction during the last few years as an
|
93
103
|
alternative to callbacks, above all in the Javascript community. While promises
|
@@ -96,7 +106,7 @@ found to offer enough of a benefit. Promises still cause split logic, are quite
|
|
96
106
|
verbose and provide a non-native exception handling mechanism. In addition, they
|
97
107
|
do not make it easier to debug your code.
|
98
108
|
|
99
|
-
|
109
|
+
## Why is awaiting implicit? Why not use explicit async/await?
|
100
110
|
|
101
111
|
Actually, async/await was contemplated while developing Polyphony, but at a
|
102
112
|
certain point it was decided to abandon these methods / decorators in favor of a
|
@@ -108,7 +118,7 @@ Instead, we have decided to make blocking operations implicit and thus allow the
|
|
108
118
|
use of common APIs such as `Kernel#sleep` or `IO.popen` in a transparent manner.
|
109
119
|
After all, these APIs in their stock form block execution just as well.
|
110
120
|
|
111
|
-
|
121
|
+
## Why use `Fiber#transfer` and not `Fiber#resume`?
|
112
122
|
|
113
123
|
The API for `Fiber.yield`/`Fiber#resume` is stateful and is intended for the
|
114
124
|
asymmetric execution of coroutines. This is useful when using generators, or
|
@@ -118,7 +128,7 @@ between them, which is much easier to achieve using `Fiber#transfer`. In
|
|
118
128
|
addition, using `Fiber#transfer` allows us to perform blocking operations from
|
119
129
|
the main fiber, which is not possible when using `Fiber#resume`.
|
120
130
|
|
121
|
-
|
131
|
+
## Why does Polyphony reimplements core APIs such as `IO#read` and `Kernel#sleep`?
|
122
132
|
|
123
133
|
Polyphony "patches" some Ruby core and stdlib APIs, providing behavioraly
|
124
134
|
compatible fiber-aware implementations. We believe Polyphony has the potential
|
@@ -126,7 +136,7 @@ to profoundly change the way concurrent Ruby apps are written. Polyphony is
|
|
126
136
|
therefore designed to feel as much as possible like an integral part of the Ruby
|
127
137
|
runtime.
|
128
138
|
|
129
|
-
|
139
|
+
## Why is Polyphony not split into multiple gems?
|
130
140
|
|
131
141
|
Polyphony is currently at an experimental stage, and its different APIs are
|
132
142
|
still in flux. For that reason, all the different parts of Polyphony are
|
@@ -134,7 +144,7 @@ currently kept in a single gem. Once things stabilize, and as Polyphony
|
|
134
144
|
approaches version 1.0, it will be split into separate gems, each with its own
|
135
145
|
functionality.
|
136
146
|
|
137
|
-
|
147
|
+
## Can I use Polyphony in a multithreaded program?
|
138
148
|
|
139
149
|
Yes, as of version 0.27 Polyphony implements per-thread fiber-scheduling. It is
|
140
150
|
however important to note that Polyphony places the emphasis on a multi-fiber
|
@@ -148,7 +158,7 @@ are such a better fit for I/O bound Ruby programs. Threads should really be used
|
|
148
158
|
when performing synchronous operations that are not fiber-aware, such as running
|
149
159
|
an expensive SQLite query, or some other expensive system call.
|
150
160
|
|
151
|
-
|
161
|
+
## How Does Polyphony Fit Into the Ruby's Future Concurrency Plans
|
152
162
|
|
153
163
|
To our understanding, two things are currently on the horizon when it comes to
|
154
164
|
concurrency in Ruby: [auto-fibers](https://bugs.ruby-lang.org/issues/13618), and
|
@@ -167,18 +177,18 @@ Polyphony's fiber-based concurrency model. Guilds will allow true parallelism
|
|
167
177
|
and together with Polyphony will allow taking full advantage of multiple CPU
|
168
178
|
cores in a single Ruby process.
|
169
179
|
|
170
|
-
|
180
|
+
## Can I run Rails using Polyphony?
|
171
181
|
|
172
182
|
We haven't yet tested Rails with Polyphony, but most probably not. We do plan to
|
173
183
|
support running Rails in an eventual release.
|
174
184
|
|
175
|
-
|
185
|
+
## How can I contribute to Polyphony?
|
176
186
|
|
177
187
|
The Polyphony repository is at
|
178
188
|
[https://github.com/digital-fabric/polyphony](https://github.com/digital-fabric/polyphony).
|
179
189
|
Feel free to create issues and contribute pull requests.
|
180
190
|
|
181
|
-
|
191
|
+
## Who is behind this project?
|
182
192
|
|
183
193
|
I'm Sharon Rosner, an independent software developer living in France. Here's my
|
184
194
|
[github profile](https://github.com/ciconia). You can contact me by writing to
|
@@ -1,11 +1,8 @@
|
|
1
1
|
---
|
2
2
|
layout: page
|
3
3
|
title: Installing Polyphony
|
4
|
-
nav_order: 1
|
5
4
|
parent: Getting Started
|
6
|
-
|
7
|
-
prev_title: Home
|
8
|
-
next_title: Tutorial
|
5
|
+
nav_order: 1
|
9
6
|
---
|
10
7
|
# Installing Polyphony
|
11
8
|
|
@@ -13,8 +10,7 @@ next_title: Tutorial
|
|
13
10
|
|
14
11
|
In order to use Polyphony you need to have:
|
15
12
|
|
16
|
-
- Linux or MacOS (
|
17
|
-
being)
|
13
|
+
- Linux or MacOS (support for Windows will come at a later stage)
|
18
14
|
- Ruby (MRI) 2.6 or newer
|
19
15
|
|
20
16
|
## Installing the Polyphony Gem
|