itimer 10 → 11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/itimer.rb +10 -10
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31a2f127807ede55d36f8f74116f823eca7f8def
4
- data.tar.gz: a340698ca3f78e48428cb8a8d77d1ef2dfcd296e
3
+ metadata.gz: b4987a91d7f5173e0891c1048c28536157ac91e9
4
+ data.tar.gz: f29d869ff2bb37bf390a1dc31dbd5726da85d5b7
5
5
  SHA512:
6
- metadata.gz: 5afd778973f6b45d9a83f1cc76738d3a2380b2460af1050d639e6fdbdd339399313598656b13c2636e977985ee39b641f15e0c8c22e05f05ffa1fcebf1282dd2
7
- data.tar.gz: a05f0e2934ab0e8eacb3157f597b5f6eceafb7c1852003986cadce297a633a9d2583665413e7a04be4859cacae367871d9abcd8e838fa17f609db3a8f2e333dc
6
+ metadata.gz: 2205c2bf075eaf13f14ad8d416e61c7c56a85b1eeda06afbe7a394798757724644f3ba249186e980479fbbd49fdbe4a06ba28e3fbc62df9724b373eada328485
7
+ data.tar.gz: 0cb968fdea5a7d268871e878fab01b7f7a8c76f83f068a825cace8e71f654c1a8798c9d8794a5cd7360da5bfad24c618299773289bee6c7dcc4fdb66ecacafc6
@@ -21,32 +21,32 @@ module Itimer
21
21
 
22
22
  catch_name = "itimer_#{@counter}"
23
23
 
24
- prev_handler = Signal.trap 'ALRM' do
25
- begin
26
- raise klass
27
- rescue klass
28
- throw(catch_name, $!)
29
- end
30
- end
31
-
32
24
  timed_out = true
33
25
  @active_timeout = absolute_timeout
34
26
 
35
27
  exception = catch(catch_name) do
28
+ prev_handler = Signal.trap 'ALRM' do
29
+ begin
30
+ raise klass
31
+ rescue klass
32
+ throw(catch_name, $!)
33
+ end
34
+ end
35
+
36
36
  set(:real, seconds)
37
37
  begin
38
38
  ret = yield
39
39
  timed_out = false
40
40
  ensure
41
41
  @active_timeout = prev_timeout
42
+ Signal.trap('ALRM', prev_handler)
43
+
42
44
  now = Time.now
43
45
  if prev_timeout && prev_timeout - now > 0
44
46
  set(:real, prev_timeout - now)
45
47
  else
46
48
  set(:real, 0)
47
49
  end
48
-
49
- Signal.trap('ALRM', prev_handler)
50
50
  end
51
51
  end
52
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itimer
3
3
  version: !ruby/object:Gem::Version
4
- version: '10'
4
+ version: '11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Mueller
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-04 00:00:00.000000000 Z
12
+ date: 2015-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.2.2
64
+ rubygems_version: 2.4.5
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Timeout replacement using POSIX interval timers