Skip to content

Commit 1733926

Browse files
committed
Channel::Buffer::Ticker is now a subclass of Timer.
1 parent b88af96 commit 1733926

File tree

1 file changed

+2
-45
lines changed

1 file changed

+2
-45
lines changed

lib/concurrent/channel/buffer/ticker.rb

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,13 @@
11
require 'concurrent/constants'
22
require 'concurrent/utility/monotonic_time'
33
require 'concurrent/channel/tick'
4-
require 'concurrent/channel/buffer/base'
4+
require 'concurrent/channel/buffer/timer'
55

66
module Concurrent
77
class Channel
88
module Buffer
99

10-
class Ticker < Base
11-
12-
def put(item)
13-
false
14-
end
15-
16-
def offer(item)
17-
false
18-
end
19-
20-
def take
21-
# a Go timer will block forever if stopped
22-
loop do
23-
tick = do_poll
24-
return tick if tick != Concurrent::NULL
25-
Thread.pass
26-
end
27-
end
28-
29-
def next
30-
# a Go timer will block forever if stopped
31-
# it will always return `true` for more
32-
loop do
33-
tick = do_poll
34-
return tick, true if tick != Concurrent::NULL
35-
Thread.pass
36-
end
37-
end
38-
39-
def poll
40-
do_poll
41-
end
10+
class Ticker < Timer
4211

4312
private
4413

@@ -48,18 +17,6 @@ def ns_initialize(interval)
4817
self.capacity = 1
4918
end
5019

51-
def ns_size
52-
0
53-
end
54-
55-
def ns_empty?
56-
false
57-
end
58-
59-
def ns_full?
60-
true
61-
end
62-
6320
def do_poll
6421
synchronize do
6522
if !ns_closed? && (now = Concurrent.monotonic_time) >= @next_tick

0 commit comments

Comments
 (0)