File tree Expand file tree Collapse file tree 7 files changed +27
-0
lines changed Expand file tree Collapse file tree 7 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,11 @@ private function setupTimer(TimerInterface $timer)
138
138
return $ timer ;
139
139
}
140
140
141
+ public function isTimerActive (TimerInterface $ timer )
142
+ {
143
+ return $ this ->timers ->contains ($ timer );
144
+ }
145
+
141
146
public function tick ()
142
147
{
143
148
$ this ->loop ->run (\libev \EventLoop::RUN_ONCE );
Original file line number Diff line number Diff line change @@ -203,6 +203,11 @@ public function cancelTimer(TimerInterface $timer)
203
203
}
204
204
}
205
205
206
+ public function isTimerActive (TimerInterface $ timer )
207
+ {
208
+ return $ this ->timers ->contains ($ timer );
209
+ }
210
+
206
211
public function tick ()
207
212
{
208
213
event_base_loop ($ this ->base , EVLOOP_ONCE | EVLOOP_NONBLOCK );
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ public function removeStream($stream);
16
16
public function addTimer ($ interval , $ callback );
17
17
public function addPeriodicTimer ($ interval , $ callback );
18
18
public function cancelTimer (TimerInterface $ timer );
19
+ public function isTimerActive (TimerInterface $ timer );
19
20
20
21
public function tick ();
21
22
public function run ();
Original file line number Diff line number Diff line change @@ -89,6 +89,11 @@ public function cancelTimer(TimerInterface $timer)
89
89
$ this ->timers ->cancel ($ timer );
90
90
}
91
91
92
+ public function isTimerActive (TimerInterface $ timer )
93
+ {
94
+ return $ this ->timers ->contains ($ timer );
95
+ }
96
+
92
97
protected function getNextEventTimeInMicroSeconds ()
93
98
{
94
99
$ nextEvent = $ this ->timers ->getFirst ();
Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ public function isPeriodic()
56
56
return $ this ->periodic ;
57
57
}
58
58
59
+ public function isActive ()
60
+ {
61
+ return $ this ->loop ->isTimerActive ($ this );
62
+ }
63
+
59
64
public function cancel ()
60
65
{
61
66
$ this ->loop ->cancelTimer ($ this );
Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ public function getCallback();
10
10
public function setData ($ data );
11
11
public function getData ();
12
12
public function isPeriodic ();
13
+ public function isActive ();
13
14
public function cancel ();
14
15
}
Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ public function add(TimerInterface $timer)
45
45
$ this ->scheduler ->insert ($ timer , -$ scheduledAt );
46
46
}
47
47
48
+ public function contains (TimerInterface $ timer )
49
+ {
50
+ return $ this ->timers ->contains ($ timer );
51
+ }
52
+
48
53
public function cancel (TimerInterface $ timer )
49
54
{
50
55
$ this ->timers ->detach ($ timer );
You can’t perform that action at this time.
0 commit comments