timers 4.1.1 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/timers.rb +24 -3
- data/lib/timers/events.rb +138 -111
- data/lib/timers/group.rb +144 -129
- data/lib/timers/interval.rb +58 -0
- data/lib/timers/timer.rb +147 -125
- data/lib/timers/version.rb +23 -1
- data/lib/timers/wait.rb +63 -44
- metadata +25 -53
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -17
- data/.rspec +0 -5
- data/.travis.yml +0 -18
- data/AUTHORS.md +0 -15
- data/CHANGES.md +0 -54
- data/Gemfile +0 -6
- data/LICENSE +0 -23
- data/README.md +0 -103
- data/Rakefile +0 -7
- data/spec/cancel_spec.rb +0 -46
- data/spec/events_spec.rb +0 -57
- data/spec/every_spec.rb +0 -34
- data/spec/group_spec.rb +0 -254
- data/spec/performance_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -19
- data/spec/strict_spec.rb +0 -37
- data/spec/timeout_spec.rb +0 -29
- data/timers.gemspec +0 -23
metadata
CHANGED
@@ -1,94 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Samuel Williams
|
7
8
|
- Tony Arcieri
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
15
17
|
requirements:
|
16
18
|
- - ">="
|
17
19
|
- !ruby/object:Gem::Version
|
18
20
|
version: '0'
|
19
|
-
|
20
|
-
type: :runtime
|
21
|
+
type: :development
|
21
22
|
prerelease: false
|
22
|
-
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
|
29
|
+
name: covered
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
29
31
|
requirements:
|
30
32
|
- - ">="
|
31
33
|
- !ruby/object:Gem::Version
|
32
34
|
version: '0'
|
33
|
-
name: rake
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
|
-
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
43
45
|
requirements:
|
44
46
|
- - "~>"
|
45
47
|
- !ruby/object:Gem::Version
|
46
|
-
version: 3.0
|
47
|
-
name: rspec
|
48
|
+
version: '3.0'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
|
-
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0
|
55
|
-
description:
|
55
|
+
version: '3.0'
|
56
|
+
description:
|
56
57
|
email:
|
57
|
-
- tony.arcieri@gmail.com
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- ".coveralls.yml"
|
63
|
-
- ".gitignore"
|
64
|
-
- ".rspec"
|
65
|
-
- ".travis.yml"
|
66
|
-
- AUTHORS.md
|
67
|
-
- CHANGES.md
|
68
|
-
- Gemfile
|
69
|
-
- LICENSE
|
70
|
-
- README.md
|
71
|
-
- Rakefile
|
72
62
|
- lib/timers.rb
|
73
63
|
- lib/timers/events.rb
|
74
64
|
- lib/timers/group.rb
|
65
|
+
- lib/timers/interval.rb
|
75
66
|
- lib/timers/timer.rb
|
76
67
|
- lib/timers/version.rb
|
77
68
|
- lib/timers/wait.rb
|
78
|
-
|
79
|
-
- spec/events_spec.rb
|
80
|
-
- spec/every_spec.rb
|
81
|
-
- spec/group_spec.rb
|
82
|
-
- spec/performance_spec.rb
|
83
|
-
- spec/spec_helper.rb
|
84
|
-
- spec/strict_spec.rb
|
85
|
-
- spec/timeout_spec.rb
|
86
|
-
- timers.gemspec
|
87
|
-
homepage: https://github.com/celluloid/timers
|
69
|
+
homepage: https://github.com/socketry/timers
|
88
70
|
licenses:
|
89
71
|
- MIT
|
90
72
|
metadata: {}
|
91
|
-
post_install_message:
|
73
|
+
post_install_message:
|
92
74
|
rdoc_options: []
|
93
75
|
require_paths:
|
94
76
|
- lib
|
@@ -96,25 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
78
|
requirements:
|
97
79
|
- - ">="
|
98
80
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
81
|
+
version: '2.5'
|
100
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
83
|
requirements:
|
102
84
|
- - ">="
|
103
85
|
- !ruby/object:Gem::Version
|
104
86
|
version: '0'
|
105
87
|
requirements: []
|
106
|
-
|
107
|
-
|
108
|
-
signing_key:
|
88
|
+
rubygems_version: 3.1.2
|
89
|
+
signing_key:
|
109
90
|
specification_version: 4
|
110
|
-
summary:
|
111
|
-
|
112
|
-
test_files:
|
113
|
-
- spec/cancel_spec.rb
|
114
|
-
- spec/events_spec.rb
|
115
|
-
- spec/every_spec.rb
|
116
|
-
- spec/group_spec.rb
|
117
|
-
- spec/performance_spec.rb
|
118
|
-
- spec/spec_helper.rb
|
119
|
-
- spec/strict_spec.rb
|
120
|
-
- spec/timeout_spec.rb
|
91
|
+
summary: Pure Ruby one-shot and periodic timers.
|
92
|
+
test_files: []
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service-name: travis-pro
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
rvm:
|
2
|
-
- 1.9.3
|
3
|
-
- 2.0.0
|
4
|
-
- 2.1.2
|
5
|
-
- ruby-head
|
6
|
-
- jruby
|
7
|
-
- jruby-head
|
8
|
-
- rbx-2
|
9
|
-
|
10
|
-
matrix:
|
11
|
-
fast_finish: true
|
12
|
-
allow_failures:
|
13
|
-
- rvm: ruby-head
|
14
|
-
- rvm: jruby-head
|
15
|
-
- rvm: rbx-2
|
16
|
-
|
17
|
-
notifications:
|
18
|
-
irc: "irc.freenode.org#celluloid"
|
data/AUTHORS.md
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# The Celluloid timers gem is beamed directly to you from the minds of...
|
2
|
-
|
3
|
-
- Tony Arcieri <bascule@gmail.com>
|
4
|
-
- Jeremy Hinegardner
|
5
|
-
- Sean Gregory
|
6
|
-
- Chuck Remes
|
7
|
-
- Utenmiki
|
8
|
-
- Ron Evans
|
9
|
-
- Larry Lv
|
10
|
-
- Bruno Enten
|
11
|
-
- Jesse Cooke
|
12
|
-
- Nicholas Evans
|
13
|
-
- Dimitrij Denissenko
|
14
|
-
- Ryan LeCompte
|
15
|
-
- Samuel G. D. Williams
|
data/CHANGES.md
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
4.1.1 (2015-08-21)
|
2
|
-
------------------
|
3
|
-
* Remove `RubyProf` from Gemfile and a test, due to it providing no substantial benefit while increasing problems building bundles under Rubinius.
|
4
|
-
|
5
|
-
4.1.0 (2015-08-16)
|
6
|
-
------------------
|
7
|
-
* Addition of `now_and_every` method; fires block immediately, then sets recurring timer.
|
8
|
-
* Includes `now_and_after` method; does the same as above for one-shot timers: essentially a "two-shot" timer.
|
9
|
-
|
10
|
-
4.0.1 (2014-09-10)
|
11
|
-
------------------
|
12
|
-
* Memory leak fixes
|
13
|
-
* mathn fix for those crazy enough to use it
|
14
|
-
|
15
|
-
4.0.0 (2014-07-27)
|
16
|
-
------------------
|
17
|
-
* Replace Timers::Timeout with Timers::Wait
|
18
|
-
* Timers::Group#wait_interval now returns nil when no timers, a postive or
|
19
|
-
negative interval which if positive is the amount of time required to wait
|
20
|
-
and if negative, how far in the past the latest timer should have fired
|
21
|
-
* Performance improvements
|
22
|
-
|
23
|
-
3.0.1 (2014-06-27)
|
24
|
-
------------------
|
25
|
-
* Require 'set' automatically
|
26
|
-
|
27
|
-
3.0.0 (2014-06-14)
|
28
|
-
------------------
|
29
|
-
* Refactor `Timers` class into `Timers::Group`
|
30
|
-
* Add `Timers::Timeout` class for implementing timeouts
|
31
|
-
* Fix timer fudging
|
32
|
-
* Update to RSpec 3
|
33
|
-
|
34
|
-
2.0.0 (2013-12-30)
|
35
|
-
------------------
|
36
|
-
* Switch to Hitimes for high precision monotonic counters
|
37
|
-
* Removed Timers#time. Replaced with Timers#current_offset which provides a
|
38
|
-
monotonic time counter.
|
39
|
-
|
40
|
-
1.1.0
|
41
|
-
-----
|
42
|
-
* Timers#after_milliseconds and #after_ms for waiting in milliseconds
|
43
|
-
|
44
|
-
1.0.2
|
45
|
-
-----
|
46
|
-
* Handle overdue timers correctly
|
47
|
-
|
48
|
-
1.0.1
|
49
|
-
-----
|
50
|
-
* Explicitly require Forwardable from stdlib
|
51
|
-
|
52
|
-
1.0.0
|
53
|
-
-----
|
54
|
-
* Initial release
|
data/Gemfile
DELETED
data/LICENSE
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Copyright (c) 2012-14 The Celluloid Timers Developers: given in the file
|
2
|
-
AUTHORS.md at https://github.com/celluloid/timers/blob/master/AUTHORS.md
|
3
|
-
|
4
|
-
MIT License
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
a copy of this software and associated documentation files (the
|
8
|
-
"Software"), to deal in the Software without restriction, including
|
9
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
-
permit persons to whom the Software is furnished to do so, subject to
|
12
|
-
the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be
|
15
|
-
included in all copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
Timers
|
2
|
-
======
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/timers.png)](http://rubygems.org/gems/timers)
|
4
|
-
[![Build Status](https://secure.travis-ci.org/celluloid/timers.png?branch=master)](http://travis-ci.org/celluloid/timers)
|
5
|
-
[![Code Climate](https://codeclimate.com/github/celluloid/timers.png)](https://codeclimate.com/github/celluloid/timers)
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/celluloid/timers/badge.png?branch=master)](https://coveralls.io/r/celluloid/timers)
|
7
|
-
|
8
|
-
Ruby timer collections. Schedule several procs to fire after configurable delays
|
9
|
-
or at periodic intervals.
|
10
|
-
|
11
|
-
This gem is especially useful when you are faced with an API that accepts a
|
12
|
-
single timeout but you want to run multiple timers on top of it. An example of
|
13
|
-
such a library is [nio4r](https://github.com/celluloid/nio4r), a cross-platform
|
14
|
-
Ruby library for using system calls like epoll and kqueue.
|
15
|
-
|
16
|
-
Usage
|
17
|
-
-----
|
18
|
-
|
19
|
-
Create a new timer group with `Timers::Group.new`:
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
require 'timers'
|
23
|
-
|
24
|
-
timers = Timers::Group.new
|
25
|
-
```
|
26
|
-
|
27
|
-
Schedule a proc to run after 5 seconds with `Timers::Group#after`:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
five_second_timer = timers.after(5) { puts "Take five" }
|
31
|
-
```
|
32
|
-
|
33
|
-
The `five_second_timer` variable is now bound to a Timers::Timer object. To
|
34
|
-
cancel a timer, use `Timers::Timer#cancel`
|
35
|
-
|
36
|
-
Once you've scheduled a timer, you can wait until the next timer fires with `Timers::Group#wait`:
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
# Waits 5 seconds
|
40
|
-
timers.wait
|
41
|
-
|
42
|
-
# The script will now print "Take five"
|
43
|
-
```
|
44
|
-
|
45
|
-
You can schedule a block to run periodically with `Timers::Group#every`:
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
every_five_seconds = timers.every(5) { puts "Another 5 seconds" }
|
49
|
-
|
50
|
-
loop { timers.wait }
|
51
|
-
```
|
52
|
-
|
53
|
-
You can also schedule a block to run immediately and periodically with `Timers::Group#now_and_every`:
|
54
|
-
```ruby
|
55
|
-
now_and_every_five_seconds = timers.now_and_every(5) { puts "Now and in another 5 seconds" }
|
56
|
-
|
57
|
-
loop { timers.wait }
|
58
|
-
```
|
59
|
-
|
60
|
-
If you'd like another method to do the waiting for you, e.g. `Kernel.select`,
|
61
|
-
you can use `Timers::Group#wait_interval` to obtain the amount of time to wait. When
|
62
|
-
a timeout is encountered, you can fire all pending timers with `Timers::Group#fire`:
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
loop do
|
66
|
-
interval = timers.wait_interval
|
67
|
-
ready_readers, ready_writers = select readers, writers, nil, interval
|
68
|
-
|
69
|
-
if ready_readers || ready_writers
|
70
|
-
# Handle IO
|
71
|
-
...
|
72
|
-
else
|
73
|
-
# Timeout!
|
74
|
-
timers.fire
|
75
|
-
end
|
76
|
-
end
|
77
|
-
```
|
78
|
-
|
79
|
-
You can also pause and continue individual timers, or all timers:
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
paused_timer = timers.every(5) { puts "I was paused" }
|
83
|
-
|
84
|
-
paused_timer.pause
|
85
|
-
10.times { timers.wait } # will not fire paused timer
|
86
|
-
|
87
|
-
paused_timer.resume
|
88
|
-
10.times { timers.wait } # will fire timer
|
89
|
-
|
90
|
-
timers.pause
|
91
|
-
10.times { timers.wait } # will not fire any timers
|
92
|
-
|
93
|
-
timers.resume
|
94
|
-
10.times { timers.wait } # will fire all timers
|
95
|
-
```
|
96
|
-
|
97
|
-
License
|
98
|
-
-------
|
99
|
-
|
100
|
-
Copyright (c) 2014 Celluloid timers project developers (given in the file
|
101
|
-
AUTHORS.md).
|
102
|
-
|
103
|
-
Distributed under the MIT License. See LICENSE file for further details.
|
data/Rakefile
DELETED
data/spec/cancel_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
RSpec.describe Timers::Group do
|
5
|
-
it "should be able to cancel twice" do
|
6
|
-
fired = false
|
7
|
-
|
8
|
-
timer = subject.after(0.1) { fired = true }
|
9
|
-
|
10
|
-
2.times do
|
11
|
-
timer.cancel
|
12
|
-
subject.wait
|
13
|
-
end
|
14
|
-
|
15
|
-
expect(fired).to be false
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be possble to reset after cancel" do
|
19
|
-
fired = false
|
20
|
-
|
21
|
-
timer = subject.after(0.1) { fired = true }
|
22
|
-
timer.cancel
|
23
|
-
|
24
|
-
subject.wait
|
25
|
-
|
26
|
-
timer.reset
|
27
|
-
|
28
|
-
subject.wait
|
29
|
-
|
30
|
-
expect(fired).to be true
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should cancel and remove one shot timers after they fire" do
|
34
|
-
x = 0
|
35
|
-
|
36
|
-
Timers::Wait.for(2) do |remaining|
|
37
|
-
timer = subject.every(0.2) { x += 1 }
|
38
|
-
subject.after(0.1) { timer.cancel }
|
39
|
-
|
40
|
-
subject.wait
|
41
|
-
end
|
42
|
-
|
43
|
-
expect(subject.timers).to be_empty
|
44
|
-
expect(x).to be == 0
|
45
|
-
end
|
46
|
-
end
|