delayer 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayer/delayed_procedure.rb +7 -1
- data/lib/delayer/extend.rb +2 -2
- data/lib/delayer/version.rb +1 -1
- data/test/test_delayer.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b9095d6ff8a3d46813d7ca787b7ffcf13050de5a21de2ba8b63940a9394631
|
4
|
+
data.tar.gz: 1da28faf0ed99c6f87450c85c469b967ca2cdc5dc08e5bcbb629d050f1d5aa66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22cac588a6463302883fbac1ada84b6922cf84076f854c2e75757ea495ac71569b133a0955dc131ca582d08b3b175beca6fb184e778975eda172ff5846747d7b
|
7
|
+
data.tar.gz: fc1cf72aae866f8d832f9f856b44dc7dd2e29e26459715800ba4d30ce8a503e782e89e86e302b0629b73f55049a083eeba60030466290f6fef376bb38f1f78b8
|
@@ -9,9 +9,15 @@ module Delayer
|
|
9
9
|
def initialize(delayer, delay:, &proc)
|
10
10
|
@delayer = delayer
|
11
11
|
@proc = proc
|
12
|
-
|
12
|
+
case delay
|
13
|
+
when Time
|
14
|
+
@reserve_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) + delay.to_f - Time.now.to_f
|
15
|
+
else
|
16
|
+
@reserve_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) + delay.to_f
|
17
|
+
end
|
13
18
|
@left = @right = @cancel = nil
|
14
19
|
@size = 1
|
20
|
+
@procedure = nil
|
15
21
|
@delayer.class.reserve(self)
|
16
22
|
end
|
17
23
|
|
data/lib/delayer/extend.rb
CHANGED
@@ -26,7 +26,7 @@ module Delayer
|
|
26
26
|
@procedure = Procedure.new(self, &proc)
|
27
27
|
else
|
28
28
|
@procedure = DelayedProcedure.new(self, delay: delay, &proc)
|
29
|
-
|
29
|
+
end
|
30
30
|
end
|
31
31
|
|
32
32
|
# Cancel this job
|
@@ -52,6 +52,7 @@ module Delayer
|
|
52
52
|
@remain_received = false
|
53
53
|
@lock = Mutex.new
|
54
54
|
@bucket = Bucket.new(nil, nil, {}, nil)
|
55
|
+
@reserve = nil
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -163,7 +164,6 @@ module Delayer
|
|
163
164
|
# ==== Return
|
164
165
|
# self
|
165
166
|
def reserve(procedure)
|
166
|
-
priority = procedure.delayer.priority
|
167
167
|
lock.synchronize do
|
168
168
|
if @reserve
|
169
169
|
@reserve = @reserve.add(procedure)
|
data/lib/delayer/version.rb
CHANGED
data/test/test_delayer.rb
CHANGED
@@ -373,6 +373,16 @@ class TestDelayer < Test::Unit::TestCase
|
|
373
373
|
assert_equal([1, 2, 0, 3], a)
|
374
374
|
end
|
375
375
|
|
376
|
+
def test_timer_give_time
|
377
|
+
delayer = Delayer.generate_class expire: 0.01
|
378
|
+
a = []
|
379
|
+
delayer.new(delay: Time.new) { a << 0 }
|
380
|
+
|
381
|
+
delayer.run
|
382
|
+
|
383
|
+
assert_equal([0], a)
|
384
|
+
end
|
385
|
+
|
376
386
|
def test_plural_timer
|
377
387
|
delayer = Delayer.generate_class expire: 0.01
|
378
388
|
a = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiaki Asai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.1.2
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Delay the processing
|