-
Notifications
You must be signed in to change notification settings - Fork 42
/
TimerManagerInterface.php
77 lines (66 loc) · 2.04 KB
/
TimerManagerInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
* This file is part of Icicle, a library for writing asynchronous code in PHP using promises and coroutines.
*
* @copyright 2014-2015 Aaron Piotrowski. All rights reserved.
* @license Apache-2.0 See the LICENSE file that was distributed with this source code for more information.
*/
namespace Icicle\Loop\Manager;
use Icicle\Loop\Events\TimerInterface;
interface TimerManagerInterface
{
/**
* Creates a timer object connected to the manager.
*
* @param int|float $interval
* @param bool $periodic
* @param callable $callback
* @param mixed[]|null $args
*
* @return \Icicle\Loop\Events\TimerInterface
*/
public function create($interval, $periodic, callable $callback, array $args = []);
/**
* Starts the given timer if it is not already pending.
*
* @param \Icicle\Loop\Events\TimerInterface $timer
*/
public function start(TimerInterface $timer);
/**
* Cancels the given timer.
*
* @param \Icicle\Loop\Events\TimerInterface $timer
*/
public function stop(TimerInterface $timer);
/**
* Determines if the timer is pending.
*
* @param \Icicle\Loop\Events\TimerInterface $timer
*
* @return bool
*/
public function isPending(TimerInterface $timer);
/**
* Unreferences the given timer, that is, if the timer is pending in the loop, the loop should not continue running.
*
* @param \Icicle\Loop\Events\TimerInterface $timer
*/
public function unreference(TimerInterface $timer);
/**
* References a timer if it was previously unreferenced. That is, if the timer is pending the loop will continue
* running.
*
* @param \Icicle\Loop\Events\TimerInterface $timer
*/
public function reference(TimerInterface $timer);
/**
* Determines if any referenced timers are pending in the manager.
*
* @return bool
*/
public function isEmpty();
/**
* Clears all timers from the manager.
*/
public function clear();
}