ractor-tmvar 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61f2c5af774133ccaca92fd2ab9d5926d1faf7d229d60f62c7928e82c8e06cef
4
- data.tar.gz: d5e176ee4886ca2f5feea7f20c9b3989e33778b3a433e7f550e281b43c9bfb72
3
+ metadata.gz: bd148e7f28224c4301b6ec77b004a483722f53b4fdd35d3e69886d06358db39d
4
+ data.tar.gz: c6b21f4ce16240b9d5912dc6528feeb5cddcb0bac6d8dc81ea8cd0cbd0bd1ee5
5
5
  SHA512:
6
- metadata.gz: 605a25ac148a512f7d2a8c18d98e6c73cae522fb69963e7a9b5357b4165efeb044a8b0e425a2172f2ad81278a1a632a434bfeb4d22a8047e4cd44e99630a49c9
7
- data.tar.gz: 9523eb78bbef48de3b809df3a442eaa2be9df55573e2ea1e0d4a7b3692977a062ba36ca6de18182800dea1c46b0120aa50e28316d21136816af09fc4d65e5522
6
+ metadata.gz: 7272a5419621fae9ef87a3cbfd895b9a21d6429b009bb6a3af32a56c62d07a6583e7c86e4f8438e1859055755644f8e2e35ccd8f244f35a742a627b634d579d8
7
+ data.tar.gz: '08abed6a02c3e4832ef99ca5139cf625a85e66559482758371f380fa590669dc7983e0ca14896a01514a1a474254f207a8ecb7987a65029f7fbbecb7e7f0363d'
@@ -6,7 +6,7 @@ jobs:
6
6
  fail-fast: false
7
7
  matrix:
8
8
  os: [ubuntu]
9
- ruby: [head, debug]
9
+ ruby: [head, debug, '4.0']
10
10
 
11
11
  runs-on: ${{ matrix.os }}-latest
12
12
  continue-on-error: ${{ matrix.ruby == 'head' || matrix.ruby == 'debug' }}
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /vendor/
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
+ plugins:
2
+ - rubocop-rake
3
+
1
4
  AllCops:
2
- TargetRubyVersion: 2.7
3
5
  NewCops: enable
4
6
 
5
7
  Style/StringLiterals:
@@ -17,3 +19,7 @@ Metrics/ClassLength:
17
19
  Enabled: true
18
20
  Exclude:
19
21
  - "test/**/*"
22
+
23
+ Naming/PredicateMethod:
24
+ AllowedMethods:
25
+ - try_put
data/Gemfile CHANGED
@@ -9,4 +9,6 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "test-unit", "~> 3.0"
11
11
 
12
- gem "rubocop", "~> 0.80"
12
+ gem "rubocop", "~> 1.91"
13
+
14
+ gem "rubocop-rake", "~> 0.7"
data/Gemfile.lock CHANGED
@@ -1,46 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ractor-tmvar (0.2.0)
5
- ractor-tvar (~> 0.3.0)
4
+ ractor-tmvar (0.3.0)
5
+ ractor-sharing (~> 0.3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.1)
11
- parallel (1.20.1)
12
- parser (2.7.2.0)
10
+ ast (2.4.3)
11
+ json (3.0.2)
12
+ language_server-protocol (3.17.0.6)
13
+ lint_roller (1.1.0)
14
+ parallel (1.28.0)
15
+ parser (3.3.12.0)
13
16
  ast (~> 2.4.1)
14
- power_assert (1.2.0)
15
- ractor-tvar (0.3.0)
16
- rainbow (3.0.0)
17
- rake (13.0.1)
18
- regexp_parser (2.0.0)
19
- rexml (3.2.4)
20
- rubocop (0.93.1)
21
- parallel (~> 1.10)
22
- parser (>= 2.7.1.5)
17
+ racc
18
+ power_assert (3.1.0)
19
+ prism (1.9.0)
20
+ racc (1.8.1)
21
+ ractor-sharing (0.3.0)
22
+ rainbow (3.1.1)
23
+ rake (13.4.2)
24
+ regexp_parser (2.13.1)
25
+ rubocop (1.91.0)
26
+ json (>= 2.3)
27
+ language_server-protocol (~> 3.17.0.2)
28
+ lint_roller (~> 1.1.0)
29
+ parallel (>= 1.10)
30
+ parser (>= 3.3.0.2)
23
31
  rainbow (>= 2.2.2, < 4.0)
24
- regexp_parser (>= 1.8)
25
- rexml
26
- rubocop-ast (>= 0.6.0)
32
+ regexp_parser (>= 2.9.3, < 3.0)
33
+ rubocop-ast (>= 1.49.0, < 2.0)
27
34
  ruby-progressbar (~> 1.7)
28
- unicode-display_width (>= 1.4.0, < 2.0)
29
- rubocop-ast (1.2.0)
30
- parser (>= 2.7.1.5)
31
- ruby-progressbar (1.10.1)
32
- test-unit (3.3.7)
35
+ unicode-display_width (>= 2.4.0, < 4.0)
36
+ rubocop-ast (1.50.0)
37
+ parser (>= 3.3.7.2)
38
+ prism (~> 1.7)
39
+ rubocop-rake (0.7.1)
40
+ lint_roller (~> 1.1)
41
+ rubocop (>= 1.72.1)
42
+ ruby-progressbar (1.13.0)
43
+ test-unit (3.7.8)
33
44
  power_assert
34
- unicode-display_width (1.7.0)
45
+ unicode-display_width (3.3.0)
46
+ unicode-emoji (~> 4.3)
47
+ unicode-emoji (4.3.0)
35
48
 
36
49
  PLATFORMS
37
50
  ruby
51
+ x86_64-linux
38
52
 
39
53
  DEPENDENCIES
40
54
  ractor-tmvar!
41
55
  rake (~> 13.0)
42
- rubocop (~> 0.80)
56
+ rubocop (~> 1.91)
57
+ rubocop-rake (~> 0.7)
43
58
  test-unit (~> 3.0)
44
59
 
60
+ CHECKSUMS
61
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
62
+ bundler (4.0.16) sha256=d6ca5dd440c24f9abce9844cf44cc8e18c6a553de65a47efb4544137af92c47d
63
+ json (3.0.2) sha256=8e6d7e7b11384c21230430cef90b71f14849a34a1f4452796670f7c981bd19df
64
+ language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
65
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
66
+ parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970
67
+ parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
68
+ power_assert (3.1.0) sha256=fefe98ed5d3140628138f3f9f9194d6ece01f1320e69700d3c928adca7518251
69
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
70
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
71
+ ractor-sharing (0.3.0) sha256=9adb2f899e4e38f477a2d3c02368e8ff40be96b119172312253338ee1e22f63f
72
+ ractor-tmvar (0.3.0)
73
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
74
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
75
+ regexp_parser (2.13.1) sha256=5aedb6b7c35688f51e86eef17a15374dfd287c83f4ca644b2c5f3ec50a33b44b
76
+ rubocop (1.91.0) sha256=9c82b7bf391c5d7e3798c5b9996e22a1fe3bd7468e351dfdeb96140c058296d0
77
+ rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
78
+ rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
79
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
80
+ test-unit (3.7.8) sha256=689d1ca53f4d46f678b4e5d68d8e4294f87fc5e8b9238cc4de7c5727e8d65943
81
+ unicode-display_width (3.3.0) sha256=4b7aa66a4b11db50f6f7e98411215cd0dd10eaecb665d36eec5bcacb3fa0b613
82
+ unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce
83
+
45
84
  BUNDLED WITH
46
- 2.2.0.rc.2
85
+ 4.0.16
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ractor::TMVar
2
2
 
3
- TMVar for Ractor inspired by [Haskell's TMVar](https://hackage.haskell.org/package/stm-2.5.0.0/docs/Control-Concurrent-STM-TMVar.html) based on [Ractor::TVar](https://github.com/ko1/ractor-tvar).
3
+ TMVar for Ractor inspired by [Haskell's TMVar](https://hackage.haskell.org/package/stm-2.5.0.0/docs/Control-Concurrent-STM-TMVar.html) based on [Ractor::TVar](https://github.com/ko1/ractor-sharing/blob/main/docs/tvar.md).
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,11 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Please see [Ractor::TVar](https://github.com/ko1/ractor-tvar) before using this.
24
- Now we have only `value` and `value=` operations.
25
-
26
23
  ```ruby
27
- require 'ractor-tmvar'
24
+ require 'ractor/tmvar'
28
25
 
29
26
  tv1 = Ractor::TMVar.new(0)
30
27
  tv2 = Ractor::TMVar.new(0)
@@ -33,20 +30,21 @@ rs = 100.times.map do
33
30
  value1 = nil
34
31
  value2 = nil
35
32
  Ractor.atomically do
36
- # take value similar to takeTMVar in Haskell
37
- value1 = v1.value
38
- value2 = v2.value
33
+ # take value like takeTMVar in Haskell
34
+ value1 = v1.take
35
+ value2 = v2.take
39
36
  end
40
37
  Ractor.atomically do
41
- # set value similar to putTMVar in Haskell
42
- v2.value = value2 + 2
43
- v1.value = value1 + 1
38
+ # set value like putTMVar in Haskell
39
+ v2.put(value2 + 2)
40
+ v1.put(value1 + 1)
44
41
  end
45
42
  end
46
43
  end
47
- rs.each(&:take)
48
- assert_equal 100, tv1.value
49
- assert_equal 200, tv2.value
44
+ rs.each(&:value)
45
+
46
+ tv1.read #=> 100
47
+ tv2.read #=> 200
50
48
  ```
51
49
 
52
50
  ## Development
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Ractor
4
4
  class TMVar
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
data/lib/ractor/tmvar.rb CHANGED
@@ -13,7 +13,9 @@ class Ractor
13
13
  #
14
14
  # initialize TMVar
15
15
  #
16
- # @param [Object] value Value to set TVar. It needs to be shareable.
16
+ # @param [Object] value value to set. With ractor-sharing 0.3, the value is
17
+ # automatically made Ractor-shareable and the passed object is frozen.
18
+ # This behavior is provided by the upstream Ractor::TVar, not a TMVar guarantee.
17
19
  #
18
20
  # @return [TMVar]
19
21
  #
@@ -79,7 +81,9 @@ class Ractor
79
81
  # write the given value.
80
82
  # If the current value is not "empty", it retries the transaction.
81
83
  #
82
- # @param [Object] new_value neet to be shareable
84
+ # @param [Object] new_value value to set. With ractor-sharing 0.3, the value is
85
+ # automatically made Ractor-shareable and the passed object is frozen.
86
+ # This behavior is provided by the upstream Ractor::TVar, not a TMVar guarantee.
83
87
  #
84
88
  def put(new_value)
85
89
  raise Ractor::RetryTransaction if @tvar.value != EMPTY
@@ -92,7 +96,9 @@ class Ractor
92
96
  # If the value is not "empty", it will not retry and only return false.
93
97
  # If it succeed to put, it returns true.
94
98
  #
95
- # @param [Object] new_value neet to be shareable
99
+ # @param [Object] new_value value to set. With ractor-sharing 0.3, the value is
100
+ # automatically made Ractor-shareable and the passed object is frozen.
101
+ # This behavior is provided by the upstream Ractor::TVar, not a TMVar guarantee.
96
102
  #
97
103
  def try_put(new_value)
98
104
  return false if @tvar.value != EMPTY
@@ -113,7 +119,9 @@ class Ractor
113
119
  #
114
120
  # get the the value like +get+, and replace the value to the given value if the current value is not "empty"
115
121
  #
116
- # @param [Object] new_value neet to be shareable
122
+ # @param [Object] new value to set. With ractor-sharing 0.3, the value is
123
+ # automatically made Ractor-shareable and the passed object is frozen.
124
+ # This behavior is provided by the upstream Ractor::TVar, not a TMVar guarantee.
117
125
  #
118
126
  def swap(new)
119
127
  v = @tvar.value
data/ractor-tmvar.gemspec CHANGED
@@ -12,13 +12,14 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Introduce Ractor::TMVar based on Ractor::TVar"
13
13
  spec.homepage = "https://github.com/yoshitsugu/ractor-tmvar"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.2")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 4.0")
16
16
 
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
  spec.metadata["source_code_uri"] = spec.homepage
21
21
  spec.metadata["changelog_uri"] = spec.homepage
22
+ spec.metadata["rubygems_mfa_required"] = "true"
22
23
 
23
24
  # Specify which files should be added to the gem when it is released.
24
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,5 +30,5 @@ Gem::Specification.new do |spec|
29
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
31
  spec.require_paths = ["lib"]
31
32
 
32
- spec.add_runtime_dependency "ractor-tvar", "~> 0.3.0"
33
+ spec.add_dependency "ractor-sharing", "~> 0.3.0"
33
34
  end
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ractor-tmvar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshitsugu
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2020-12-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: ractor-tvar
13
+ name: ractor-sharing
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
@@ -51,7 +50,7 @@ metadata:
51
50
  homepage_uri: https://github.com/yoshitsugu/ractor-tmvar
52
51
  source_code_uri: https://github.com/yoshitsugu/ractor-tmvar
53
52
  changelog_uri: https://github.com/yoshitsugu/ractor-tmvar
54
- post_install_message:
53
+ rubygems_mfa_required: 'true'
55
54
  rdoc_options: []
56
55
  require_paths:
57
56
  - lib
@@ -59,15 +58,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
- version: 2.7.2
61
+ version: '4.0'
63
62
  required_rubygems_version: !ruby/object:Gem::Requirement
64
63
  requirements:
65
64
  - - ">="
66
65
  - !ruby/object:Gem::Version
67
66
  version: '0'
68
67
  requirements: []
69
- rubygems_version: 3.2.0.rc.2
70
- signing_key:
68
+ rubygems_version: 4.0.3
71
69
  specification_version: 4
72
70
  summary: Ractor::TMVar
73
71
  test_files: []