1 | <?php |
||
10 | class TimeoutExitStrategy implements ExitStrategy |
||
11 | { |
||
12 | private $exitTime; |
||
13 | |||
14 | /** |
||
15 | * @param int $timeout The number of seconds to consume jobs before exiting |
||
16 | */ |
||
17 | 9 | public function __construct($timeout) |
|
18 | { |
||
19 | $this->exitTime = time() + $timeout; |
||
20 | 9 | } |
|
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 4 | public function shouldExit($count) |
|
26 | { |
||
27 | if (time() >= $this->exitTime) { |
||
28 | 4 | return true; |
|
29 | } |
||
30 | |||
31 | 3 | return false; |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 4 | public function getReason() |
|
41 | } |
||
42 |