async-io 1.28.0 → 1.29.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 +4 -4
- data/.github/workflows/development.yml +55 -0
- data/README.md +1 -1
- data/lib/async/io/threads.rb +63 -0
- data/lib/async/io/version.rb +1 -1
- data/spec/async/io/tcp_socket_spec.rb +1 -1
- data/spec/async/io/threads_spec.rb +59 -0
- metadata +6 -3
- data/.travis.yml +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2244383314b8e20f44556404b4615c3ec41215a95fe823b43929e82aee8aa9a0
|
4
|
+
data.tar.gz: dfd4bb8127fa72430e2155c8b22b69308a2f961f85fcb8230f5fc09c347a3db3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2083fe88624d12833af765dd83bd4060a3b7b702d359a3efd08db72cd78f56fe33dbadaf31e98a6980cbcc50164b9557b1a258375d7fa58c9b259ecacf0494aa
|
7
|
+
data.tar.gz: 4ac435276669ae721afec8b416dc793179467d73794f5f2f34c9276d1db62fc55713a7d4950d92d41bb482674aba051bfd60cddc51f94190a31eee43cfe50222
|
@@ -0,0 +1,55 @@
|
|
1
|
+
name: Development
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ${{matrix.os}}-latest
|
8
|
+
continue-on-error: ${{matrix.experimental}}
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
os:
|
13
|
+
- ubuntu
|
14
|
+
- macos
|
15
|
+
|
16
|
+
ruby:
|
17
|
+
- 2.5
|
18
|
+
- 2.6
|
19
|
+
- 2.7
|
20
|
+
|
21
|
+
experimental: [false]
|
22
|
+
env: [""]
|
23
|
+
|
24
|
+
include:
|
25
|
+
- os: ubuntu
|
26
|
+
ruby: truffleruby
|
27
|
+
experimental: true
|
28
|
+
env: JRUBY_OPTS="--debug -X+O"
|
29
|
+
- os: ubuntu
|
30
|
+
ruby: jruby
|
31
|
+
experimental: true
|
32
|
+
- os: ubuntu
|
33
|
+
ruby: head
|
34
|
+
experimental: true
|
35
|
+
- os: ubuntu
|
36
|
+
ruby: 2.6
|
37
|
+
experimental: false
|
38
|
+
env: COVERAGE=PartialSummary,Coveralls
|
39
|
+
- os: macos
|
40
|
+
ruby: 2.7
|
41
|
+
experimental: false
|
42
|
+
env: BUNDLE_GEMFILE=gems/nio4r-2.3.gemfile
|
43
|
+
|
44
|
+
steps:
|
45
|
+
- uses: actions/checkout@v1
|
46
|
+
- uses: ruby/setup-ruby@v1
|
47
|
+
with:
|
48
|
+
ruby-version: ${{matrix.ruby}}
|
49
|
+
|
50
|
+
- name: Install dependencies
|
51
|
+
run: ${{matrix.env}} bundle install
|
52
|
+
|
53
|
+
- name: Run tests
|
54
|
+
timeout-minutes: 5
|
55
|
+
run: ${{matrix.env}} bundle exec rspec
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Async::IO provides builds on [async] and provides asynchronous wrappers for `IO`
|
|
4
4
|
|
5
5
|
[async]: https://github.com/socketry/async
|
6
6
|
|
7
|
-
[](https://github.com/socketry/async-io/actions?workflow=Development)
|
8
8
|
[](https://codeclimate.com/github/socketry/async-io)
|
9
9
|
[](https://coveralls.io/r/socketry/async-io)
|
10
10
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'notification'
|
24
|
+
|
25
|
+
module Async
|
26
|
+
module IO
|
27
|
+
class Threads
|
28
|
+
def initialize(parent: nil)
|
29
|
+
@parent = parent
|
30
|
+
end
|
31
|
+
|
32
|
+
def async(parent: (@parent or Task.current))
|
33
|
+
parent.async do |task|
|
34
|
+
notification = Async::IO::Notification.new
|
35
|
+
|
36
|
+
thread = Thread.new do
|
37
|
+
yield
|
38
|
+
ensure
|
39
|
+
notification.signal
|
40
|
+
end
|
41
|
+
|
42
|
+
task.annotate "Waiting for thread to finish..."
|
43
|
+
|
44
|
+
notification.wait
|
45
|
+
|
46
|
+
thread.value
|
47
|
+
ensure
|
48
|
+
if thread&.alive?
|
49
|
+
thread.raise(Stop)
|
50
|
+
|
51
|
+
begin
|
52
|
+
thread.join
|
53
|
+
rescue Stop
|
54
|
+
# Ignore.
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
notification&.close
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/async/io/version.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'async/io/threads'
|
24
|
+
|
25
|
+
RSpec.describe Async::IO::Threads do
|
26
|
+
include_context Async::RSpec::Reactor
|
27
|
+
|
28
|
+
describe '#async' do
|
29
|
+
it "can schedule work on a different thread" do
|
30
|
+
thread = subject.async do
|
31
|
+
Thread.current
|
32
|
+
end.wait
|
33
|
+
|
34
|
+
expect(thread).to be_kind_of Thread
|
35
|
+
expect(thread).to_not be Thread.current
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can kill thread when stopping task" do
|
39
|
+
sleeping = Async::IO::Notification.new
|
40
|
+
|
41
|
+
thread = nil
|
42
|
+
|
43
|
+
task = Async do
|
44
|
+
subject.async do
|
45
|
+
thread = Thread.current
|
46
|
+
sleeping.signal
|
47
|
+
sleep
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
sleeping.wait
|
52
|
+
|
53
|
+
task.stop
|
54
|
+
expect(thread.status).to be_nil
|
55
|
+
ensure
|
56
|
+
sleeping.close
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -116,9 +116,9 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- ".editorconfig"
|
119
|
+
- ".github/workflows/development.yml"
|
119
120
|
- ".gitignore"
|
120
121
|
- ".rspec"
|
121
|
-
- ".travis.yml"
|
122
122
|
- ".yardopts"
|
123
123
|
- Gemfile
|
124
124
|
- README.md
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/async/io/standard.rb
|
161
161
|
- lib/async/io/stream.rb
|
162
162
|
- lib/async/io/tcp_socket.rb
|
163
|
+
- lib/async/io/threads.rb
|
163
164
|
- lib/async/io/trap.rb
|
164
165
|
- lib/async/io/udp_socket.rb
|
165
166
|
- lib/async/io/unix_endpoint.rb
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- spec/async/io/stream_context.rb
|
186
187
|
- spec/async/io/stream_spec.rb
|
187
188
|
- spec/async/io/tcp_socket_spec.rb
|
189
|
+
- spec/async/io/threads_spec.rb
|
188
190
|
- spec/async/io/trap_spec.rb
|
189
191
|
- spec/async/io/udp_socket_spec.rb
|
190
192
|
- spec/async/io/unix_endpoint_spec.rb
|
@@ -236,6 +238,7 @@ test_files:
|
|
236
238
|
- spec/async/io/stream_context.rb
|
237
239
|
- spec/async/io/stream_spec.rb
|
238
240
|
- spec/async/io/tcp_socket_spec.rb
|
241
|
+
- spec/async/io/threads_spec.rb
|
239
242
|
- spec/async/io/trap_spec.rb
|
240
243
|
- spec/async/io/udp_socket_spec.rb
|
241
244
|
- spec/async/io/unix_endpoint_spec.rb
|
data/.travis.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: xenial
|
3
|
-
cache: bundler
|
4
|
-
|
5
|
-
script: bundle exec rspec
|
6
|
-
|
7
|
-
matrix:
|
8
|
-
include:
|
9
|
-
- rvm: 2.5
|
10
|
-
- rvm: 2.6
|
11
|
-
- rvm: 2.7
|
12
|
-
- rvm: 2.6
|
13
|
-
env: COVERAGE=PartialSummary,Coveralls
|
14
|
-
- rvm: truffleruby
|
15
|
-
- rvm: jruby-head
|
16
|
-
env: JRUBY_OPTS="--debug -X+O"
|
17
|
-
- rvm: ruby-head
|
18
|
-
- rvm: 2.6
|
19
|
-
os: osx
|
20
|
-
- rvm: 2.6
|
21
|
-
os: osx
|
22
|
-
gemfile: gems/nio4r-2.3.gemfile
|
23
|
-
allow_failures:
|
24
|
-
- rvm: ruby-head
|
25
|
-
- rvm: truffleruby
|
26
|
-
- rvm: jruby-head
|