File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -41,20 +41,12 @@ def initialize(opts = {})
41
41
#
42
42
# @raise [ArgumentError] if the intended execution time is not in the future
43
43
# @raise [ArgumentError] if no block is given
44
- def post ( intended_time , &block )
45
- mutex . synchronize do
46
- return false unless running?
47
- raise ArgumentError . new ( 'no block given' ) unless block_given?
48
- time = TimerSet . calculate_schedule_time ( intended_time ) . to_f
49
-
50
- if ( time - Time . now . to_f ) <= 0.01
51
- @executor . post ( &block )
52
- else
53
- @queue . push ( Task . new ( time , block ) )
54
- end
44
+ def post ( intended_time , &task )
45
+ time = TimerSet . calculate_schedule_time ( intended_time ) . to_f
46
+ if super ( time , &task )
47
+ check_processing_thread!
48
+ true
55
49
end
56
- check_processing_thread!
57
- true
58
50
end
59
51
60
52
# Begin an orderly shutdown. Tasks already in the queue will be executed,
@@ -110,6 +102,14 @@ def <=>(other)
110
102
end
111
103
end
112
104
105
+ def execute ( time , &task )
106
+ if ( time - Time . now . to_f ) <= 0.01
107
+ @executor . post ( &task )
108
+ else
109
+ @queue . push ( Task . new ( time , task ) )
110
+ end
111
+ end
112
+
113
113
# Check the status of the processing thread. This thread is responsible
114
114
# for monitoring the internal task queue and sending tasks to the
115
115
# executor when it is time for them to be processed. If there is no
You can’t perform that action at this time.
0 commit comments