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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38a6ae4b7f5e2893ad8b4d96a2c2abd5670c8d4e
4
- data.tar.gz: c9e0e58a5f1d7e5c6874c1658440060a39c6cc9d
3
+ metadata.gz: 0eb6d0a050c5e7f9abcaa0f84b59771c1279c61a
4
+ data.tar.gz: f2d0829c7284be531a1141deb69cc21fa2e2c926
5
5
  SHA512:
6
- metadata.gz: 1caef71d23d17bc09ee6321f528b5985b4596719a79fac0af58bb3042f0ac99ba46e35baf5f40c9071336940ae6c4b123bd25c07746bd42296e328e40f195cff
7
- data.tar.gz: d6aa30010eba324f2bbe6992f9722bd412953cdf90a3a136889f9a040de8b24a4b8fddeada863301ac7142a06442b07e38df8a3c3bc7b7760573e560f2597ab7
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
- @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
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)
@@ -1,3 +1,3 @@
1
1
  module Lifeguard
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-25 00:00:00.000000000 Z
12
+ date: 2016-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: better_receive