| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total |  | n/a | 0 / 0 |  | n/a | 0 / 0 | CRAP |  | n/a | 0 / 0

1 | <?php
2 | /**
3 | * This file is part of workerman.
4 | *
5 | * Licensed under The MIT License
6 | * For full copyright and license information, please see the MIT-LICENSE.txt
7 | * Redistributions of files must retain the above copyright notice.
8 | *
9 | * @author walkor<walkor@workerman.net>
10 | * @copyright walkor<walkor@workerman.net>
11 | * @link http://www.workerman.net/
12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License
13 | */
14 |
15 | declare(strict_types=1);
16 |
17 | namespace Workerman\Events;
18 |
19 | interface EventInterface
20 | {
21 | /**
22 | * Delay the execution of a callback.
23 | *
24 | * @param float $delay
25 | * @param callable(mixed...): void $func
26 | * @param array $args
27 | * @return int
28 | */
29 | public function delay(float $delay, callable $func, array $args = []): int;
30 |
31 | /**
32 | * Delete a delay timer.
33 | *
34 | * @param int $timerId
35 | * @return bool
36 | */
37 | public function offDelay(int $timerId): bool;
38 |
39 | /**
40 | * Repeatedly execute a callback.
41 | *
42 | * @param float $interval
43 | * @param callable(mixed...): void $func
44 | * @param array $args
45 | * @return int
46 | */
47 | public function repeat(float $interval, callable $func, array $args = []): int;
48 |
49 | /**
50 | * Delete a repeat timer.
51 | *
52 | * @param int $timerId
53 | * @return bool
54 | */
55 | public function offRepeat(int $timerId): bool;
56 |
57 | /**
58 | * Execute a callback when a stream resource becomes readable or is closed for reading.
59 | *
60 | * @param resource $stream
61 | * @param callable(resource): void $func
62 | * @return void
63 | */
64 | public function onReadable($stream, callable $func): void;
65 |
66 | /**
67 | * Cancel a callback of stream readable.
68 | *
69 | * @param resource $stream
70 | * @return bool
71 | */
72 | public function offReadable($stream): bool;
73 |
74 | /**
75 | * Execute a callback when a stream resource becomes writable or is closed for writing.
76 | *
77 | * @param resource $stream
78 | * @param callable(resource): void $func
79 | * @return void
80 | */
81 | public function onWritable($stream, callable $func): void;
82 |
83 | /**
84 | * Cancel a callback of stream writable.
85 | *
86 | * @param resource $stream
87 | * @return bool
88 | */
89 | public function offWritable($stream): bool;
90 |
91 | /**
92 | * Execute a callback when a signal is received.
93 | *
94 | * @param int $signal
95 | * @param callable(int): void $func
96 | * @return void
97 | */
98 | public function onSignal(int $signal, callable $func): void;
99 |
100 | /**
101 | * Cancel a callback of signal.
102 | *
103 | * @param int $signal
104 | * @return bool
105 | */
106 | public function offSignal(int $signal): bool;
107 |
108 | /**
109 | * Delete all timer.
110 | *
111 | * @return void
112 | */
113 | public function deleteAllTimer(): void;
114 |
115 | /**
116 | * Run the event loop.
117 | *
118 | * @return void
119 | */
120 | public function run(): void;
121 |
122 | /**
123 | * Stop event loop.
124 | *
125 | * @return void
126 | */
127 | public function stop(): void;
128 |
129 | /**
130 | * Get Timer count.
131 | *
132 | * @return int
133 | */
134 | public function getTimerCount(): int;
135 |
136 | /**
137 | * Set error handler.
138 | *
139 | * @param callable(\Throwable): void $errorHandler
140 | * @return void
141 | */
142 | public function setErrorHandler(callable $errorHandler): void;
143 | }