File tree Expand file tree Collapse file tree 1 file changed +2
-45
lines changed
lib/concurrent/channel/buffer Expand file tree Collapse file tree 1 file changed +2
-45
lines changed Original file line number Diff line number Diff line change 1
1
require 'concurrent/constants'
2
2
require 'concurrent/utility/monotonic_time'
3
3
require 'concurrent/channel/tick'
4
- require 'concurrent/channel/buffer/base '
4
+ require 'concurrent/channel/buffer/timer '
5
5
6
6
module Concurrent
7
7
class Channel
8
8
module Buffer
9
9
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
42
11
43
12
private
44
13
@@ -48,18 +17,6 @@ def ns_initialize(interval)
48
17
self . capacity = 1
49
18
end
50
19
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
-
63
20
def do_poll
64
21
synchronize do
65
22
if !ns_closed? && ( now = Concurrent . monotonic_time ) >= @next_tick
You can’t perform that action at this time.
0 commit comments