polyphony 0.27 → 0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/CHANGELOG.md +13 -0
  4. data/Gemfile +12 -1
  5. data/Gemfile.lock +83 -5
  6. data/Rakefile +4 -0
  7. data/TODO.md +11 -20
  8. data/docs/_config.yml +15 -0
  9. data/docs/_includes/nav.html +47 -0
  10. data/docs/_sass/custom/custom.scss +5 -0
  11. data/docs/_sass/overrides.scss +45 -0
  12. data/docs/assets/img/echo-fibers.svg +1 -0
  13. data/docs/assets/img/sleeping-fiber.svg +1 -0
  14. data/docs/faq.md +182 -0
  15. data/docs/getting-started/installing.md +10 -2
  16. data/docs/getting-started/tutorial.md +333 -26
  17. data/docs/getting-started.md +10 -0
  18. data/docs/index.md +91 -0
  19. data/docs/technical-overview/concurrency.md +78 -16
  20. data/docs/technical-overview/design-principles.md +7 -0
  21. data/docs/technical-overview/exception-handling.md +57 -9
  22. data/docs/technical-overview/extending.md +7 -0
  23. data/docs/technical-overview/fiber-scheduling.md +128 -18
  24. data/docs/technical-overview.md +10 -0
  25. data/docs/user-guide/web-server.md +7 -0
  26. data/docs/user-guide.md +10 -0
  27. data/examples/core/xx-deadlock.rb +8 -0
  28. data/examples/core/xx-state-machine.rb +51 -0
  29. data/examples/core/xx-trace.rb +80 -0
  30. data/examples/interfaces/pg_notify.rb +35 -0
  31. data/examples/io/xx-httparty.rb +31 -6
  32. data/examples/io/xx-irb.rb +1 -11
  33. data/examples/io/xx-switch.rb +15 -0
  34. data/ext/gyro/gyro.c +77 -38
  35. data/ext/gyro/gyro.h +15 -5
  36. data/ext/gyro/gyro_ext.c +3 -0
  37. data/ext/gyro/thread.c +47 -32
  38. data/ext/gyro/tracing.c +11 -0
  39. data/lib/polyphony/core/global_api.rb +11 -4
  40. data/lib/polyphony/core/supervisor.rb +1 -0
  41. data/lib/polyphony/core/thread_pool.rb +44 -35
  42. data/lib/polyphony/extensions/fiber.rb +19 -9
  43. data/lib/polyphony/extensions/io.rb +14 -14
  44. data/lib/polyphony/extensions/socket.rb +3 -3
  45. data/lib/polyphony/irb.rb +13 -0
  46. data/lib/polyphony/postgres.rb +15 -0
  47. data/lib/polyphony/trace.rb +98 -0
  48. data/lib/polyphony/version.rb +1 -1
  49. data/lib/polyphony.rb +1 -0
  50. data/polyphony.gemspec +21 -12
  51. data/test/helper.rb +3 -2
  52. data/test/test_fiber.rb +53 -3
  53. data/test/test_global_api.rb +12 -0
  54. data/test/test_gyro.rb +2 -2
  55. data/test/test_supervisor.rb +12 -0
  56. data/test/test_thread.rb +12 -0
  57. data/test/test_thread_pool.rb +75 -0
  58. data/test/test_throttler.rb +6 -0
  59. data/test/test_trace.rb +66 -0
  60. metadata +99 -9
  61. data/docs/README.md +0 -36
  62. data/docs/summary.md +0 -60
  63. data/docs/technical-overview/faq.md +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3c496d74c1fb5545a3111d9a116c55268cde00298feaea546dab8ba199fb359
4
- data.tar.gz: 57810b0cac851c5364ed831549a5d06beef73b13f9f6615d2d9ee0558397ccfd
3
+ metadata.gz: 96b63d0e57950ea2983cfadab521cceaba97180fce4269575715a856d1beebdd
4
+ data.tar.gz: 42580ebe9a11620cc546474837983ae959aa239fba3a0c926eb62a40d9b66773
5
5
  SHA512:
6
- metadata.gz: b0df4d81349f7226544a158e4f46b2e24f71db9496c5ccee0911634f848d0bdaaebc7ac9ae231e8a29892858212f6782a4f4d8a639121249b13cf4793c133482
7
- data.tar.gz: 9ac4943327e356c2bf8f6a5a72d75787d1e71983c2aec6784eb6daa242bee3f79c49c379e716b2fb8fc235bf48fc7d2a50825f24a541c129dab12d0b34b1da9b
6
+ metadata.gz: b4f4f02373ff3f9f1780a90b5df09bdd8efc95dbe28bed7787915a474961fe1f687baeb6cf46431eda65a6719c9e98a46b44807d71496723d84fbe7b0841a582
7
+ data.tar.gz: 1582cdfa47593230dc64f1676a514cea09e36db37048e138f41f75a626a91acac0e6dd34d6962597b4016a57afb125a9913c1111474f3470543e75f1b4915b88
data/.gitignore CHANGED
@@ -52,4 +52,7 @@ build-iPhoneSimulator/
52
52
  test.rb
53
53
  .vscode
54
54
 
55
- lib/gyro_ext.bundle
55
+ lib/gyro_ext.bundle
56
+
57
+ _site
58
+ .sass-cache
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ 0.28 2020-01-27
2
+ ---------------
3
+
4
+ * Accept block in Supervisor#initialize
5
+ * Refactor `ThreadPool`
6
+ * Implement fiber switch events for `TracePoint`
7
+ * Add optional tag parameter to #spin
8
+ * Correctly increment ref count for indefinite sleep
9
+ * Add `irb` adapter
10
+ * Add support for listen/notify to postgres adapter
11
+ * Use `:waiting`, `:runnable`, `:running`, `:dead` for fiber states
12
+ * Move docs to https://digital-fabric.github.io/polyphony/
13
+
1
14
  0.27 2020-01-19
2
15
  ---------------
3
16
 
data/Gemfile CHANGED
@@ -1,3 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ # gem "jekyll", "~> 3.8.6"
6
+ # gem "jekyll-remote-theme"
7
+ # gem "jekyll-seo-tag"
8
+ # gem "just-the-docs"
9
+
10
+ # # gem "github-pages", group: :jekyll_plugins
11
+
12
+ # group :jekyll_plugins do
13
+ # gem "jekyll-feed", "~> 0.6"
14
+ # end
data/Gemfile.lock CHANGED
@@ -1,26 +1,73 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyphony (0.27)
4
+ polyphony (0.28)
5
5
  modulation (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
10
12
  ansi (1.5.0)
13
+ ast (2.4.0)
11
14
  builder (3.2.4)
15
+ colorator (1.1.0)
16
+ concurrent-ruby (1.1.5)
12
17
  docile (1.3.2)
18
+ em-websocket (0.5.1)
19
+ eventmachine (>= 0.12.9)
20
+ http_parser.rb (~> 0.6.0)
21
+ eventmachine (1.2.7)
22
+ ffi (1.12.1)
23
+ forwardable-extended (2.6.0)
13
24
  hiredis (0.6.3)
14
25
  http_parser.rb (0.6.0)
15
26
  httparty (0.17.0)
16
27
  mime-types (~> 3.0)
17
28
  multi_xml (>= 0.5.2)
18
- json (2.1.0)
29
+ i18n (0.9.5)
30
+ concurrent-ruby (~> 1.0)
31
+ jaro_winkler (1.5.4)
32
+ jekyll (3.8.6)
33
+ addressable (~> 2.4)
34
+ colorator (~> 1.0)
35
+ em-websocket (~> 0.5)
36
+ i18n (~> 0.7)
37
+ jekyll-sass-converter (~> 1.0)
38
+ jekyll-watch (~> 2.0)
39
+ kramdown (~> 1.14)
40
+ liquid (~> 4.0)
41
+ mercenary (~> 0.3.3)
42
+ pathutil (~> 0.9)
43
+ rouge (>= 1.7, < 4)
44
+ safe_yaml (~> 1.0)
45
+ jekyll-remote-theme (0.4.1)
46
+ addressable (~> 2.0)
47
+ jekyll (>= 3.5, < 5.0)
48
+ rubyzip (>= 1.3.0)
49
+ jekyll-sass-converter (1.5.2)
50
+ sass (~> 3.4)
51
+ jekyll-seo-tag (2.6.1)
52
+ jekyll (>= 3.3, < 5.0)
53
+ jekyll-watch (2.2.1)
54
+ listen (~> 3.0)
55
+ json (2.3.0)
56
+ just-the-docs (0.2.7)
57
+ jekyll (~> 3.8.5)
58
+ jekyll-seo-tag (~> 2.0)
59
+ rake (~> 12.3.1)
60
+ kramdown (1.17.0)
61
+ liquid (4.0.3)
62
+ listen (3.2.1)
63
+ rb-fsevent (~> 0.10, >= 0.10.3)
64
+ rb-inotify (~> 0.9, >= 0.9.10)
19
65
  localhost (1.1.4)
66
+ mercenary (0.3.6)
20
67
  mime-types (3.3.1)
21
68
  mime-types-data (~> 3.2015)
22
69
  mime-types-data (3.2019.1009)
23
- minitest (5.11.3)
70
+ minitest (5.13.0)
24
71
  minitest-reporters (1.4.2)
25
72
  ansi
26
73
  builder
@@ -28,17 +75,43 @@ GEM
28
75
  ruby-progressbar
29
76
  modulation (1.0)
30
77
  multi_xml (0.6.0)
78
+ parallel (1.19.1)
79
+ parser (2.7.0.2)
80
+ ast (~> 2.4.0)
81
+ pathutil (0.16.2)
82
+ forwardable-extended (~> 2.6)
31
83
  pg (1.1.3)
32
- rake (13.0.1)
84
+ public_suffix (4.0.3)
85
+ rainbow (3.0.0)
86
+ rake (12.3.3)
33
87
  rake-compiler (1.0.5)
34
88
  rake
89
+ rb-fsevent (0.10.3)
90
+ rb-inotify (0.10.1)
91
+ ffi (~> 1.0)
35
92
  redis (4.1.0)
93
+ rouge (3.15.0)
94
+ rubocop (0.79.0)
95
+ jaro_winkler (~> 1.5.1)
96
+ parallel (~> 1.10)
97
+ parser (>= 2.7.0.1)
98
+ rainbow (>= 2.2.2, < 4.0)
99
+ ruby-progressbar (~> 1.7)
100
+ unicode-display_width (>= 1.4.0, < 1.7)
36
101
  ruby-progressbar (1.10.1)
102
+ rubyzip (2.0.0)
103
+ safe_yaml (1.0.5)
104
+ sass (3.7.4)
105
+ sass-listen (~> 4.0.0)
106
+ sass-listen (4.0.0)
107
+ rb-fsevent (~> 0.9, >= 0.9.4)
108
+ rb-inotify (~> 0.9, >= 0.9.7)
37
109
  simplecov (0.17.1)
38
110
  docile (~> 1.1)
39
111
  json (>= 1.8, < 3)
40
112
  simplecov-html (~> 0.10.0)
41
113
  simplecov-html (0.10.2)
114
+ unicode-display_width (1.6.1)
42
115
 
43
116
  PLATFORMS
44
117
  ruby
@@ -47,13 +120,18 @@ DEPENDENCIES
47
120
  hiredis (= 0.6.3)
48
121
  http_parser.rb (~> 0.6.0)
49
122
  httparty (= 0.17.0)
123
+ jekyll (~> 3.8.6)
124
+ jekyll-remote-theme (~> 0.4.1)
125
+ jekyll-seo-tag (~> 2.6.1)
126
+ just-the-docs (~> 0.2.7)
50
127
  localhost (= 1.1.4)
51
- minitest (= 5.11.3)
128
+ minitest (= 5.13.0)
52
129
  minitest-reporters (= 1.4.2)
53
130
  pg (= 1.1.3)
54
131
  polyphony!
55
132
  rake-compiler (= 1.0.5)
56
133
  redis (= 4.1.0)
134
+ rubocop (= 0.79.0)
57
135
  simplecov (= 0.17.1)
58
136
 
59
137
  BUNDLED WITH
data/Rakefile CHANGED
@@ -15,6 +15,10 @@ task :test do
15
15
  exec 'ruby test/run.rb'
16
16
  end
17
17
 
18
+ task :docs do
19
+ exec 'RUBYOPT=-W0 jekyll serve -s docs'
20
+ end
21
+
18
22
  task default: %w[compile]
19
23
 
20
24
  CLEAN.include "**/*.o", "**/*.so", "**/*.bundle", "**/*.jar", "pkg", "tmp"
data/TODO.md CHANGED
@@ -1,16 +1,18 @@
1
- ## 0.27 Multithreaded fiber scheduling
1
+ ## 0.29 Multithreaded fiber scheduling - some rough corners
2
2
 
3
+ - Docs: explain difference between `sleep` and `suspend`
4
+ - Write about threads: scheduling, etc
3
5
  - `Gyro_schedule_fiber` - schedule using fiber's associated thread (store thread
4
6
  ref in fiber), instead of current thread
5
7
  - Check why first call to `#sleep` returns too early in tests. Check the
6
8
  sleep behaviour in a spawned thread.
7
9
 
8
- ## 0.28 Working Sinatra application
10
+ ## 0.30 Working Sinatra application
9
11
 
10
12
  - app with database access (postgresql)
11
13
  - benchmarks!
12
14
 
13
- ## 0.29 Sidekick
15
+ ## 0.31 Sidekick
14
16
 
15
17
  Plan of action:
16
18
 
@@ -18,13 +20,13 @@ Plan of action:
18
20
  - test performance
19
21
  - proceed from there
20
22
 
21
- ## 0.30 Testing && Docs
23
+ ## 0.32 Testing && Docs
22
24
 
23
25
  - Pull out redis/postgres code, put into new `polyphony-xxx` gems
24
26
 
25
- ## 0.31 Integration
27
+ ## 0.33 Integration
26
28
 
27
- ## 0.32 Real IO#gets and IO#read
29
+ ## 0.34 Real IO#gets and IO#read
28
30
 
29
31
  - More tests
30
32
  - Implement some basic stuff missing:
@@ -34,24 +36,13 @@ Plan of action:
34
36
  - `IO.foreach`
35
37
  - `Process.waitpid`
36
38
 
37
- ## 0.32 Support for multithreaded apps
38
-
39
- - Move fiber scheduling to the `Thread` class
40
- - Gyro selector conforming to the selector interface:
41
-
42
- ```ruby
43
- class Selector
44
- def wait
45
- end
46
- ```
47
-
48
- - Better separation between
39
+ ## 0.35 Rails
49
40
 
50
41
  - Rails?
51
42
 
52
- # DNS
43
+ ## 0.36 DNS
53
44
 
54
- ## DNS client
45
+ ### DNS client
55
46
 
56
47
  ```ruby
57
48
  ip_address = DNS.lookup('google.com', 'A')
data/docs/_config.yml ADDED
@@ -0,0 +1,15 @@
1
+ title: "Polyphony"
2
+
3
+ remote_theme: pmarsceill/just-the-docs
4
+ color_scheme: nil
5
+
6
+ search_enabled: true
7
+ # Enable support for hyphenated search words:
8
+ search_tokenizer_separator: /[\s/]+/
9
+
10
+ plugins:
11
+ - jekyll-remote-theme
12
+
13
+ aux_links:
14
+ "Polyphony on GitHub":
15
+ - "//github.com/digital-fabric/polyphony"
@@ -0,0 +1,47 @@
1
+ <nav role="navigation" aria-label="Main navigation">
2
+ <ul class="navigation-list">
3
+ {%- assign pages_list = site.html_pages | sort:"nav_order" -%}
4
+ {%- for node in pages_list -%}
5
+ {%- unless node.nav_exclude -%}
6
+ {%- if node.parent == nil -%}
7
+ <li class="navigation-list-item
8
+ {% if page.url == node.url %} active{% endif %}
9
+ {% if node.section %}section-title{% endif %}
10
+ ">
11
+ {%- if page.parent == node.title or page.grand_parent == node.title -%}
12
+ {%- assign first_level_url = node.section_link | node.url | absolute_url -%}
13
+ {%- endif -%}
14
+ {%- if node.section -%}
15
+ <span class="section-title">{{ node.title }}</span>
16
+ {%- else -%}
17
+ <a href="{{ node.url | absolute_url }}" class="navigation-list-link{% if page.url == node.url %} active{% endif %}">{{ node.title }}</a>
18
+ {%- endif -%}
19
+ {%- if node.has_children -%}
20
+ {%- assign children_list = site.html_pages | where: "parent", node.title | sort:"nav_order" -%}
21
+ <ul class="navigation-list-child-list ">
22
+ {%- for child in children_list -%}
23
+ <li class="navigation-list-item {% if page.url == child.url or page.parent == child.title %} active{% endif %}">
24
+ {%- if page.url == child.url or page.parent == child.title -%}
25
+ {%- assign second_level_url = child.url | absolute_url -%}
26
+ {%- endif -%}
27
+ <a href="{{ child.url | absolute_url }}" class="navigation-list-link{% if page.url == child.url %} active{% endif %}">{{ child.title }}</a>
28
+ {%- if child.has_children -%}
29
+ {%- assign grand_children_list = site.html_pages | where: "parent", child.title | sort:"nav_order" -%}
30
+ <ul class="navigation-list-child-list">
31
+ {%- for grand_child in grand_children_list -%}
32
+ <li class="navigation-list-item {% if page.url == grand_child.url %} active{% endif %}">
33
+ <a href="{{ grand_child.url | absolute_url }}" class="navigation-list-link{% if page.url == grand_child.url %} active{% endif %}">{{ grand_child.title }}</a>
34
+ </li>
35
+ {%- endfor -%}
36
+ </ul>
37
+ {%- endif -%}
38
+ </li>
39
+ {%- endfor -%}
40
+ </ul>
41
+ {%- endif -%}
42
+ </li>
43
+ {%- endif -%}
44
+ {%- endunless -%}
45
+ {%- endfor -%}
46
+ </ul>
47
+ </nav>
@@ -0,0 +1,5 @@
1
+ $link-color: $blue-000;
2
+
3
+ .img-figure {
4
+ text-align: center;
5
+ }
@@ -0,0 +1,45 @@
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
+ &.active {
31
+ &::before {
32
+ color: $body-text-color;
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ a.navigation-list-link {
39
+ color: $nav-child-link-color;
40
+ font-weight: 600;
41
+ }
42
+
43
+ a.navigation-list-link:hover {
44
+ color: $link-color;
45
+ }