lifeguard 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lifeguard/infinite_threadpool.rb +6 -20
- data/lib/lifeguard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb6d0a050c5e7f9abcaa0f84b59771c1279c61a
|
4
|
+
data.tar.gz: f2d0829c7284be531a1141deb69cc21fa2e2c926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 062da13fa9b240289439a23f71d39c0c8a6b308331c4fdcb231962ed30fdeb0d17aa33b2acae0a15d5fef15f57d23a797fde9e9cc5784dc966403f934cb2f2c7
|
7
|
+
data.tar.gz: b6ff5d59113351955ff6ca80b1a6810ba3d6d275f42a86de5f6200a63023411b9a246a3cb975146b9f7fda54b50b4dde9cf4e594034732ec110611b9e1958b70
|
@@ -6,34 +6,20 @@ module Lifeguard
|
|
6
6
|
|
7
7
|
def initialize(opts = {})
|
8
8
|
super(opts)
|
9
|
-
@queued_jobs = ::Queue.new
|
10
9
|
@shutdown = false
|
11
10
|
@super_async_mutex = ::Mutex.new
|
12
11
|
end
|
13
12
|
|
14
|
-
# Handle to original async method
|
15
|
-
# for check_queued_jobs to use directly
|
16
|
-
alias_method :super_async, :async
|
17
|
-
|
18
13
|
def async(*args, &block)
|
19
14
|
return false if @shutdown
|
20
|
-
@queued_jobs << { :args => args, :block => block }
|
21
|
-
check_queued_jobs
|
22
|
-
|
23
|
-
return true
|
24
|
-
end
|
25
|
-
|
26
|
-
def check_queued_jobs
|
27
|
-
loop do
|
28
|
-
break if busy?
|
29
|
-
break if @queued_jobs.size <= 0
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
16
|
+
if busy?
|
17
|
+
block.call(*args) rescue nil
|
18
|
+
else
|
19
|
+
super(*args, &block)
|
36
20
|
end
|
21
|
+
|
22
|
+
return true
|
37
23
|
end
|
38
24
|
|
39
25
|
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.
|
4
|
+
version: 0.2.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-08-
|
12
|
+
date: 2016-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: better_receive
|