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.
@@ -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
@@ -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