backports 3.20.0 → 3.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/backports/ractor/ractor.rb +28 -5
- data/lib/backports/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa5429b607594bcd855bad1a66bbfdc01e3facb1f76be0c338fd549b502ec1c4
|
4
|
+
data.tar.gz: e7e08e840cc7559df5708a0bfa5d1499a3e809fb9bf79b260e4c98e7ca634c60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e59f88a7ef8c1487cc1c1fb04d28a96d44b26d8cc5379a6ea9f18edfca62d97fe0b84c27a03c600a6137febf9096917f0ec1d7a52574fc536f7c345b2e256af
|
7
|
+
data.tar.gz: 9e732e7626034ae45dd1daf0cd54f20319854f27f041c5624e8c96d287a66ffeee780e8d0c142472e8b88cba597b65ee300b161b811acade9aaa697ff3352ff7
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
8
8
|
|
9
9
|
Note: [Next major version (X-mas 2021?)](https://github.com/marcandre/backports/issues/139) may drop support for Ruby < 2.2, please comment.
|
10
10
|
|
11
|
+
## [3.20.1](https://github.com/marcandre/backports/compare/v3.20.0...v3.20.1) - 2021-01-03
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
* Added `Ractor.[]` and `[]=` [#161]
|
16
|
+
* `Ractor.current` fixed from threads [#161]
|
17
|
+
|
11
18
|
## [3.20.0](https://github.com/marcandre/backports/compare/v3.19.0...v3.20.0) - 2020-12-30
|
12
19
|
|
13
20
|
### Added
|
@@ -8,6 +8,8 @@ class Ractor
|
|
8
8
|
require_relative 'queues'
|
9
9
|
require_relative 'sharing'
|
10
10
|
|
11
|
+
RactorThreadGroups = ::ObjectSpace::WeakMap.new # ThreadGroup => Ractor
|
12
|
+
private_constant :RactorThreadGroups
|
11
13
|
# Implementation notes
|
12
14
|
#
|
13
15
|
# Uses one `Thread` for each `Ractor`, as well as queues for communication
|
@@ -37,7 +39,7 @@ class Ractor
|
|
37
39
|
if Ractor.main == nil # then initializing main Ractor
|
38
40
|
@ractor_thread = ::Thread.current
|
39
41
|
@ractor_origin = nil
|
40
|
-
@ractor_thread.thread_variable_set(:
|
42
|
+
@ractor_thread.thread_variable_set(:backports_ractor, self)
|
41
43
|
else
|
42
44
|
@ractor_origin = caller(1, 1).first.split(':in `').first
|
43
45
|
|
@@ -47,10 +49,12 @@ class Ractor
|
|
47
49
|
end
|
48
50
|
|
49
51
|
private def ractor_thread_start(args, block)
|
50
|
-
Thread.new do
|
52
|
+
::Thread.new do
|
51
53
|
@ractor_thread = Thread.current
|
52
|
-
@ractor_thread_group = ThreadGroup.new
|
53
|
-
|
54
|
+
@ractor_thread_group = ThreadGroup.new
|
55
|
+
RactorThreadGroups[@ractor_thread_group] = self
|
56
|
+
@ractor_thread_group.add(@ractor_thread)
|
57
|
+
::Thread.current.thread_variable_set(:backports_ractor, self)
|
54
58
|
result = nil
|
55
59
|
begin
|
56
60
|
result = instance_exec(*args, &block)
|
@@ -139,6 +143,19 @@ class Ractor
|
|
139
143
|
ractor_incoming_queue.pop(&block)
|
140
144
|
end
|
141
145
|
|
146
|
+
def [](key)
|
147
|
+
Ractor.current.ractor_locals[key]
|
148
|
+
end
|
149
|
+
|
150
|
+
def []=(key, value)
|
151
|
+
Ractor.current.ractor_locals[key] = value
|
152
|
+
end
|
153
|
+
|
154
|
+
# @api private
|
155
|
+
def ractor_locals
|
156
|
+
@ractor_locals ||= {}.compare_by_identity
|
157
|
+
end
|
158
|
+
|
142
159
|
class << self
|
143
160
|
def yield(value, move: false)
|
144
161
|
value = ractor_isolate(value, move)
|
@@ -198,7 +215,8 @@ class Ractor
|
|
198
215
|
end
|
199
216
|
|
200
217
|
def current
|
201
|
-
Thread.current.thread_variable_get(:
|
218
|
+
Thread.current.thread_variable_get(:backports_ractor) ||
|
219
|
+
Thread.current.thread_variable_set(:backports_ractor, ractor_find_current)
|
202
220
|
end
|
203
221
|
|
204
222
|
def count
|
@@ -222,6 +240,11 @@ class Ractor
|
|
222
240
|
private def ractor_init
|
223
241
|
@ractor_shareable = ::ObjectSpace::WeakMap.new
|
224
242
|
@main = Ractor.new { nil }
|
243
|
+
RactorThreadGroups[::ThreadGroup::Default] = @main
|
244
|
+
end
|
245
|
+
|
246
|
+
private def ractor_find_current
|
247
|
+
RactorThreadGroups[Thread.current.group]
|
225
248
|
end
|
226
249
|
end
|
227
250
|
|
data/lib/backports/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Backports
|
2
|
-
VERSION = "3.20.
|
2
|
+
VERSION = "3.20.1" unless Backports.constants.include? :VERSION # the guard is against a redefinition warning that happens on Travis
|
3
3
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.20.
|
4
|
+
version: 3.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Lafortune
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Essential backports that enable many of the nice features of Ruby for
|
14
14
|
earlier versions.
|