lifeguard 0.0.9 → 0.1.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/lib/lifeguard/infinite_threadpool.rb +17 -13
- data/lib/lifeguard/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38a6ae4b7f5e2893ad8b4d96a2c2abd5670c8d4e
|
4
|
+
data.tar.gz: c9e0e58a5f1d7e5c6874c1658440060a39c6cc9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1caef71d23d17bc09ee6321f528b5985b4596719a79fac0af58bb3042f0ac99ba46e35baf5f40c9071336940ae6c4b123bd25c07746bd42296e328e40f195cff
|
7
|
+
data.tar.gz: d6aa30010eba324f2bbe6992f9722bd412953cdf90a3a136889f9a040de8b24a4b8fddeada863301ac7142a06442b07e38df8a3c3bc7b7760573e560f2597ab7
|
@@ -8,28 +8,32 @@ module Lifeguard
|
|
8
8
|
super(opts)
|
9
9
|
@queued_jobs = ::Queue.new
|
10
10
|
@shutdown = false
|
11
|
+
@super_async_mutex = ::Mutex.new
|
11
12
|
end
|
12
13
|
|
14
|
+
# Handle to original async method
|
15
|
+
# for check_queued_jobs to use directly
|
16
|
+
alias_method :super_async, :async
|
17
|
+
|
13
18
|
def async(*args, &block)
|
14
19
|
return false if @shutdown
|
15
|
-
|
20
|
+
@queued_jobs << { :args => args, :block => block }
|
16
21
|
check_queued_jobs
|
17
|
-
job_started = super
|
18
|
-
|
19
|
-
unless job_started
|
20
|
-
@queued_jobs << { :args => args, :block => block }
|
21
|
-
end
|
22
22
|
|
23
|
-
|
23
|
+
return true
|
24
24
|
end
|
25
25
|
|
26
26
|
def check_queued_jobs
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
loop do
|
28
|
+
break if busy?
|
29
|
+
break if @queued_jobs.size <= 0
|
30
|
+
|
31
|
+
@super_async_mutex.synchronize do
|
32
|
+
break if busy?
|
33
|
+
queued_job = @queued_jobs.pop
|
34
|
+
super_async(*queued_job[:args], &queued_job[:block])
|
35
|
+
end
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def kill!(*args)
|
data/lib/lifeguard/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifeguard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: better_receive
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.5.1
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: A Supervised threadpool implementation in ruby.
|