async-container 0.16.5 → 0.16.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/container/generic.rb +13 -4
- data/lib/async/container/notify/pipe.rb +0 -16
- data/lib/async/container/version.rb +1 -1
- metadata +30 -73
- data/.editorconfig +0 -6
- data/.github/workflows/development.yml +0 -36
- data/.gitignore +0 -21
- data/.rspec +0 -3
- data/.yardopts +0 -1
- data/Gemfile +0 -19
- data/Guardfile +0 -14
- data/README.md +0 -140
- data/async-container.gemspec +0 -34
- data/examples/async.rb +0 -22
- data/examples/channel.rb +0 -45
- data/examples/channels/client.rb +0 -103
- data/examples/container.rb +0 -33
- data/examples/isolate.rb +0 -36
- data/examples/minimal.rb +0 -94
- data/examples/test.rb +0 -51
- data/examples/threads.rb +0 -25
- data/examples/title.rb +0 -13
- data/examples/udppipe.rb +0 -35
- data/spec/async/container/controller_spec.rb +0 -148
- data/spec/async/container/dots.rb +0 -29
- data/spec/async/container/forked_spec.rb +0 -61
- data/spec/async/container/hybrid_spec.rb +0 -36
- data/spec/async/container/notify/notify.rb +0 -19
- data/spec/async/container/notify/pipe_spec.rb +0 -48
- data/spec/async/container/notify_spec.rb +0 -56
- data/spec/async/container/shared_examples.rb +0 -80
- data/spec/async/container/threaded_spec.rb +0 -35
- data/spec/async/container_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -21
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2018, 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/rspec/reactor'
|
24
|
-
|
25
|
-
RSpec.shared_examples_for Async::Container do
|
26
|
-
it "can run concurrently" do
|
27
|
-
input, output = IO.pipe
|
28
|
-
|
29
|
-
subject.async do
|
30
|
-
output.write "Hello World"
|
31
|
-
end
|
32
|
-
|
33
|
-
subject.wait
|
34
|
-
|
35
|
-
output.close
|
36
|
-
expect(input.read).to be == "Hello World"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "can run concurrently" do
|
40
|
-
subject.async(name: "Sleepy Jerry") do |task, instance|
|
41
|
-
3.times do |i|
|
42
|
-
instance.name = "Counting Sheep #{i}"
|
43
|
-
|
44
|
-
sleep 0.01
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
subject.wait
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#sleep' do
|
52
|
-
it "can sleep for a short time" do
|
53
|
-
subject.spawn do
|
54
|
-
sleep(0.2 * QUANTUM)
|
55
|
-
raise "Boom"
|
56
|
-
end
|
57
|
-
|
58
|
-
subject.sleep(0.1 * QUANTUM)
|
59
|
-
expect(subject.statistics).to have_attributes(failures: 0)
|
60
|
-
|
61
|
-
subject.wait
|
62
|
-
|
63
|
-
expect(subject.statistics).to have_attributes(failures: 1)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#stop' do
|
68
|
-
it 'can stop the child process' do
|
69
|
-
subject.spawn do
|
70
|
-
sleep(1)
|
71
|
-
end
|
72
|
-
|
73
|
-
is_expected.to be_running
|
74
|
-
|
75
|
-
subject.stop
|
76
|
-
|
77
|
-
is_expected.to_not be_running
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2018, 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/container/threaded"
|
24
|
-
|
25
|
-
require_relative 'shared_examples'
|
26
|
-
|
27
|
-
RSpec.describe Async::Container::Threaded do
|
28
|
-
subject {described_class.new}
|
29
|
-
|
30
|
-
it_behaves_like Async::Container
|
31
|
-
|
32
|
-
it "should not be multiprocess" do
|
33
|
-
expect(described_class).to_not be_multiprocess
|
34
|
-
end
|
35
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2017, 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/container"
|
24
|
-
|
25
|
-
RSpec.describe Async::Container do
|
26
|
-
it "can get processor count" do
|
27
|
-
expect(Async::Container.processor_count).to be >= 1
|
28
|
-
end
|
29
|
-
|
30
|
-
it "can get best container class" do
|
31
|
-
expect(Async::Container.best_container_class).to_not be_nil
|
32
|
-
end
|
33
|
-
|
34
|
-
subject {Async::Container.new}
|
35
|
-
|
36
|
-
it "can get best container class" do
|
37
|
-
expect(subject).to_not be_nil
|
38
|
-
|
39
|
-
subject.stop
|
40
|
-
end
|
41
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'covered/rspec'
|
4
|
-
|
5
|
-
# Shared rspec helpers:
|
6
|
-
require "async/rspec"
|
7
|
-
|
8
|
-
if RUBY_PLATFORM =~ /darwin/i
|
9
|
-
QUANTUM = 2.0
|
10
|
-
else
|
11
|
-
QUANTUM = 1.0
|
12
|
-
end
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
# Enable flags like --only-failures and --next-failure
|
16
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
17
|
-
|
18
|
-
config.expect_with :rspec do |c|
|
19
|
-
c.syntax = :expect
|
20
|
-
end
|
21
|
-
end
|