timers 4.3.3 → 4.3.4

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
  SHA256:
3
- metadata.gz: a9f471bfb9cac57f9462498ab12527eded7533318cec13604a10d32b159c6689
4
- data.tar.gz: 69802b0774101037596274f2acf114c3f4234875ed8a82146e8ef1075407bf6d
3
+ metadata.gz: 6aaa0d481ea83db607add1809f3f5d96b085bddf5bda6fa17165c18316c4c527
4
+ data.tar.gz: 8995d8268bd1c49b047e0fe0d1bf252d8c943962d05eee4026601b952cacc339
5
5
  SHA512:
6
- metadata.gz: f15934803658ec4b1d0d7b4a8ea92c9a21e2267544ec11c9619604288264c7f0add19dd12b71a0680827d6d37b853192d98266f29b06ef27cb36e53408f8c67b
7
- data.tar.gz: a50a935d7b73681b4b751341c6eda0143c64beb9d469641ea68b8481cd1c36bd16ad21f7ec274f06d1389b53c5849e06b20182d3faea6497f64773d8fba2dae6
6
+ metadata.gz: 3d5a69bc7f7e32e02365476d9a25e97dbe72c572497874356603554ecc28f5ee88821af1a2bfd4239a232f0d7a9ef0048c45a1909eefa7faae3619c51c3ec87a
7
+ data.tar.gz: 6521553ef5271c9191aa0dc4f23a65c3eb776293273784e46597bda0a92ae0d97aa915e4f9c25869b8923f516fe23ed2bf389abf34e1cb76ac6f5484d6d927da
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ @BC�S���rr�H�rW
2
+ ���۳�Jc�ݠb�1ɥY���(���.W����Li����"^�'���&��.����y�2Sk\Ї7�?.q(IK ��(��?�:�s���A�(L������f8)��(0�[�
3
+ RʞY��s����`�L[�D*t��R} MG�?�����l�Jƒ���ߩTu���mx��G��
4
+ �W8��� u��4ټn_�D|N���[����m�1��l�U�a�Y�N.�?' 0fTtH��_r邧��i�KW�^��س�ڲN�R�o�2��~e$'��=��%���@�� H��5ŭ#�
data/lib/timers/events.rb CHANGED
@@ -1,24 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2014-2022, by Samuel Williams.
5
+ # Copyright, 2014-2016, by Tony Arcieri.
6
+ # Copyright, 2014, by Lavir the Whiolet.
7
+ # Copyright, 2015, by Utenmiki.
8
+ # Copyright, 2015, by Donovan Keme.
9
+ # Copyright, 2021, by Wander Hillen.
22
10
 
23
11
  require_relative "timer"
24
12
  require_relative "priority_heap"
@@ -69,6 +57,8 @@ module Timers
69
57
 
70
58
  # Add an event at the given time.
71
59
  def schedule(time, callback)
60
+ flush!
61
+
72
62
  handle = Handle.new(time.to_f, callback)
73
63
 
74
64
  @queue << handle
@@ -111,5 +101,11 @@ module Timers
111
101
  @sequence.push(handle)
112
102
  end
113
103
  end
104
+
105
+ def flush!
106
+ while @queue.last&.cancelled?
107
+ @queue.pop
108
+ end
109
+ end
114
110
  end
115
111
  end
data/lib/timers/group.rb CHANGED
@@ -1,24 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2014-2022, by Samuel Williams.
5
+ # Copyright, 2014-2016, by Tony Arcieri.
6
+ # Copyright, 2015, by Donovan Keme.
7
+ # Copyright, 2015, by Tommy Ong Gia Phu.
22
8
 
23
9
  require "set"
24
10
  require "forwardable"
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2022, by Samuel Williams.
22
5
 
23
6
  module Timers
24
7
  # A collection of timers which may fire at different times
@@ -1,25 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
3
4
  # Copyright, 2021, by Wander Hillen.
4
- # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
5
+ # Copyright, 2021-2022, by Samuel Williams.
23
6
 
24
7
  module Timers
25
8
  # A priority queue implementation using a standard binary minheap. It uses straight comparison
@@ -87,30 +70,19 @@ module Timers
87
70
  return self
88
71
  end
89
72
 
90
- private
91
-
92
- # Validate the heap invariant.
93
- def validate!(index = 0)
94
- if value = @contents[index]
95
- left_index = index*2 + 1
96
- if left_value = @contents[left_index]
97
- unless value < left_value
98
- raise "Invalid left index from #{index}!"
99
- end
100
-
101
- validate!(left_index)
102
- end
103
-
104
- right_index = left_index + 1
105
- if right_value = @contents[right_index]
106
- unless value < right_value
107
- raise "Invalid right index from #{index}!"
108
- end
109
-
110
- validate!(right_index)
111
- end
112
- end
73
+ # Empties out the heap, discarding all elements
74
+ def clear!
75
+ @contents = []
76
+ end
77
+
78
+ # Validate the heap invariant. Every element except the root must not be smaller than
79
+ # its parent element. Note that it MAY be equal.
80
+ def valid?
81
+ # notice we skip index 0 on purpose, because it has no parent
82
+ (1..(@contents.size - 1)).all? { |e| @contents[e] >= @contents[(e - 1) / 2] }
113
83
  end
84
+
85
+ private
114
86
 
115
87
  def swap(i, j)
116
88
  @contents[i], @contents[j] = @contents[j], @contents[i]
data/lib/timers/timer.rb CHANGED
@@ -1,24 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2014-2022, by Samuel Williams.
5
+ # Copyright, 2014-2017, by Tony Arcieri.
6
+ # Copyright, 2014, by Utenmiki.
7
+ # Copyright, 2014, by Lin Jen-Shin.
8
+ # Copyright, 2017, by Vít Ondruch.
22
9
 
23
10
  module Timers
24
11
  # An individual timer set to fire a given proc at a given time. A timer is
@@ -1,25 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2016, by Tony Arcieri.
5
+ # Copyright, 2014-2022, by Samuel Williams.
6
+ # Copyright, 2015, by Donovan Keme.
22
7
 
23
8
  module Timers
24
- VERSION = "4.3.3"
9
+ VERSION = "4.3.4"
25
10
  end
data/lib/timers/wait.rb CHANGED
@@ -1,24 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2014-2022, by Samuel Williams.
5
+ # Copyright, 2014-2016, by Tony Arcieri.
6
+ # Copyright, 2015, by Utenmiki.
7
+ # Copyright, 2015, by Donovan Keme.
22
8
 
23
9
  require_relative "interval"
24
10
 
data/lib/timers.rb CHANGED
@@ -1,24 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2016, by Tony Arcieri.
5
+ # Copyright, 2012, by Ryan LeCompte.
6
+ # Copyright, 2012, by Nicholas Evans.
7
+ # Copyright, 2012, by Dimitrij Denissenko.
8
+ # Copyright, 2013, by Chuck Remes.
9
+ # Copyright, 2013, by Ron Evans.
10
+ # Copyright, 2013, by Sean Gregory.
11
+ # Copyright, 2013, by Utenmiki.
12
+ # Copyright, 2013, by Jeremy Hinegardner.
13
+ # Copyright, 2014, by Larry Lv.
14
+ # Copyright, 2014, by Bruno Enten.
15
+ # Copyright, 2014-2022, by Samuel Williams.
16
+ # Copyright, 2014, by Mike Bourgeous.
22
17
 
23
18
  require_relative "timers/version"
24
19
 
data/license.md ADDED
@@ -0,0 +1,48 @@
1
+ # MIT License
2
+
3
+ Copyright, 2012-2017, by Tony Arcieri.
4
+ Copyright, 2012, by Ryan LeCompte.
5
+ Copyright, 2012, by Jesse Cooke.
6
+ Copyright, 2012, by Nicholas Evans.
7
+ Copyright, 2012, by Dimitrij Denissenko.
8
+ Copyright, 2013, by Chuck Remes.
9
+ Copyright, 2013, by Ron Evans.
10
+ Copyright, 2013, by Sean Gregory.
11
+ Copyright, 2013-2015, by Utenmiki.
12
+ Copyright, 2013, by Jeremy Hinegardner.
13
+ Copyright, 2014, by Larry Lv.
14
+ Copyright, 2014, by Bruno Enten.
15
+ Copyright, 2014-2022, by Samuel Williams.
16
+ Copyright, 2014, by Mike Bourgeous.
17
+ Copyright, 2014, by Klaus Trainer.
18
+ Copyright, 2014, by Lin Jen-Shin.
19
+ Copyright, 2014, by Lavir the Whiolet.
20
+ Copyright, 2015-2016, by Donovan Keme.
21
+ Copyright, 2015, by Tommy Ong Gia Phu.
22
+ Copyright, 2015, by Will Jessop.
23
+ Copyright, 2016, by Ryunosuke SATO.
24
+ Copyright, 2016, by Atul Bhosale.
25
+ Copyright, 2016, by Feram.
26
+ Copyright, 2017, by Vít Ondruch.
27
+ Copyright, 2017-2020, by Olle Jonsson.
28
+ Copyright, 2020, by Tim Smith.
29
+ Copyright, 2021, by Wander Hillen.
30
+ Copyright, 2022, by Yoshiki Takagi.
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in all
40
+ copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,110 @@
1
+ # Timers
2
+
3
+ Collections of one-shot and periodic timers, intended for use with event loops such as [async](https://github.com/socketry/async).
4
+
5
+ [![Development Status](https://github.com/socketry/timers/workflows/Test/badge.svg)](https://github.com/socketry/timers/actions?workflow=Test)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ``` ruby
12
+ gem 'timers'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install timers
22
+
23
+ ## Usage
24
+
25
+ Create a new timer group with `Timers::Group.new`:
26
+
27
+ ``` ruby
28
+ require 'timers'
29
+
30
+ timers = Timers::Group.new
31
+ ```
32
+
33
+ Schedule a proc to run after 5 seconds with `Timers::Group#after`:
34
+
35
+ ``` ruby
36
+ five_second_timer = timers.after(5) { puts "Take five" }
37
+ ```
38
+
39
+ The `five_second_timer` variable is now bound to a Timers::Timer object. To
40
+ cancel a timer, use `Timers::Timer#cancel`
41
+
42
+ Once you've scheduled a timer, you can wait until the next timer fires with `Timers::Group#wait`:
43
+
44
+ ``` ruby
45
+ # Waits 5 seconds
46
+ timers.wait
47
+
48
+ # The script will now print "Take five"
49
+ ```
50
+
51
+ You can schedule a block to run periodically with `Timers::Group#every`:
52
+
53
+ ``` ruby
54
+ every_five_seconds = timers.every(5) { puts "Another 5 seconds" }
55
+
56
+ loop { timers.wait }
57
+ ```
58
+
59
+ You can also schedule a block to run immediately and periodically with `Timers::Group#now_and_every`:
60
+
61
+ ``` ruby
62
+ now_and_every_five_seconds = timers.now_and_every(5) { puts "Now and in another 5 seconds" }
63
+
64
+ loop { timers.wait }
65
+ ```
66
+
67
+ If you'd like another method to do the waiting for you, e.g. `Kernel.select`,
68
+ you can use `Timers::Group#wait_interval` to obtain the amount of time to wait. When
69
+ a timeout is encountered, you can fire all pending timers with `Timers::Group#fire`:
70
+
71
+ ``` ruby
72
+ loop do
73
+ interval = timers.wait_interval
74
+ ready_readers, ready_writers = select readers, writers, nil, interval
75
+
76
+ if ready_readers || ready_writers
77
+ # Handle IO
78
+ ...
79
+ else
80
+ # Timeout!
81
+ timers.fire
82
+ end
83
+ end
84
+ ```
85
+
86
+ You can also pause and continue individual timers, or all timers:
87
+
88
+ ``` ruby
89
+ paused_timer = timers.every(5) { puts "I was paused" }
90
+
91
+ paused_timer.pause
92
+ 10.times { timers.wait } # will not fire paused timer
93
+
94
+ paused_timer.resume
95
+ 10.times { timers.wait } # will fire timer
96
+
97
+ timers.pause
98
+ 10.times { timers.wait } # will not fire any timers
99
+
100
+ timers.resume
101
+ 10.times { timers.wait } # will fire all timers
102
+ ```
103
+
104
+ ## Contributing
105
+
106
+ 1. Fork it
107
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
108
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
109
+ 4. Push to the branch (`git push origin my-new-feature`)
110
+ 5. Create new Pull Request
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,15 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.3
4
+ version: 4.3.4
5
5
  platform: ruby
6
6
  authors:
7
- - Samuel Williams
8
7
  - Tony Arcieri
8
+ - Samuel Williams
9
+ - "//de"
10
+ - Wander Hillen
11
+ - Jeremy Hinegardner
12
+ - skinnyjames
13
+ - Chuck Remes
14
+ - utenmiki
15
+ - Olle Jonsson
16
+ - deadprogrammer
17
+ - takiy33
18
+ - Larry Lv
19
+ - Lin Jen-Shin
20
+ - Ryunosuke SATO
21
+ - Tommy Ong Gia Phu
22
+ - Atul Bhosale
23
+ - Bruno Enten
24
+ - Dimitrij Denissenko
25
+ - Donovan Keme
26
+ - Feram
27
+ - Jesse Cooke
28
+ - Klaus Trainer
29
+ - Lavir the Whiolet
30
+ - Mike Bourgeous
31
+ - Ryan LeCompte
32
+ - Tim Smith
33
+ - Vít Ondruch
34
+ - Will Jessop
35
+ - Yoshiki Takagi
36
+ - nicholas a. evans
37
+ - tommyogp
9
38
  autorequire:
10
39
  bindir: bin
11
- cert_chain: []
12
- date: 2021-02-13 00:00:00.000000000 Z
40
+ cert_chain:
41
+ - |
42
+ -----BEGIN CERTIFICATE-----
43
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
44
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
45
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
46
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
47
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
48
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
49
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
50
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
51
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
52
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
53
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
54
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
55
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
56
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
57
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
58
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
59
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
60
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
61
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
62
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
63
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
64
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
65
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
66
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
67
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
68
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
69
+ -----END CERTIFICATE-----
70
+ date: 2022-09-02 00:00:00.000000000 Z
13
71
  dependencies:
14
72
  - !ruby/object:Gem::Dependency
15
73
  name: bundler
@@ -40,19 +98,47 @@ dependencies:
40
98
  - !ruby/object:Gem::Version
41
99
  version: '0'
42
100
  - !ruby/object:Gem::Dependency
43
- name: rspec
101
+ name: bake-test
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '0.1'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '0.1'
114
+ - !ruby/object:Gem::Dependency
115
+ name: bake-test-external
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '0.2'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '0.2'
128
+ - !ruby/object:Gem::Dependency
129
+ name: sus
44
130
  requirement: !ruby/object:Gem::Requirement
45
131
  requirements:
46
132
  - - "~>"
47
133
  - !ruby/object:Gem::Version
48
- version: '3.0'
134
+ version: '0.13'
49
135
  type: :development
50
136
  prerelease: false
51
137
  version_requirements: !ruby/object:Gem::Requirement
52
138
  requirements:
53
139
  - - "~>"
54
140
  - !ruby/object:Gem::Version
55
- version: '3.0'
141
+ version: '0.13'
56
142
  description:
57
143
  email:
58
144
  executables: []
@@ -67,6 +153,8 @@ files:
67
153
  - lib/timers/timer.rb
68
154
  - lib/timers/version.rb
69
155
  - lib/timers/wait.rb
156
+ - license.md
157
+ - readme.md
70
158
  homepage: https://github.com/socketry/timers
71
159
  licenses:
72
160
  - MIT
@@ -86,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
174
  - !ruby/object:Gem::Version
87
175
  version: '0'
88
176
  requirements: []
89
- rubygems_version: 3.1.2
177
+ rubygems_version: 3.3.7
90
178
  signing_key:
91
179
  specification_version: 4
92
180
  summary: Pure Ruby one-shot and periodic timers.
metadata.gz.sig ADDED
Binary file