1 | <?php |
||
25 | class Timer implements TimerInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $maxIterations; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | protected $iterations; |
||
36 | |||
37 | /** |
||
38 | * @var BaseTimerInterface |
||
39 | */ |
||
40 | private $timer; |
||
41 | |||
42 | /** |
||
43 | * @var Delegate |
||
44 | */ |
||
45 | private $task; |
||
46 | |||
47 | /** |
||
48 | * @var DeferredInterface |
||
49 | */ |
||
50 | private $deferred = null; |
||
51 | |||
52 | /** |
||
53 | * @var mixed |
||
54 | */ |
||
55 | private $lastResult; |
||
56 | |||
57 | /** |
||
58 | * @param LoopInterface $loop |
||
59 | * @param callable $task |
||
60 | * @param int|float $interval |
||
61 | * @param bool $periodic |
||
62 | * @param int $count |
||
63 | * |
||
64 | * @throws \InvalidArgumentException |
||
65 | */ |
||
66 | public function __construct(LoopInterface $loop, callable $task, $interval, $periodic = false, $count = null) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function interval() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function iterations() |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function maxIterations() |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function isActive() |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function cancel() |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function then(callable $onSucceed = null, callable $onRejected = null, callable $onNotify = null) |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function done(callable $onSucceed = null, callable $onRejected = null, callable $onNotify = null) |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function otherwise(callable $onRejected) |
||
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | public function always(callable $onFulfilledOrRejected, callable $notify = null) |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | public function state() |
||
165 | |||
166 | /** |
||
167 | * @return \Cubiche\Core\Async\Promise\Deferred |
||
168 | */ |
||
169 | protected function deferred() |
||
177 | |||
178 | /** |
||
179 | */ |
||
180 | private function onTick() |
||
198 | } |
||
199 |