Swoole\Event
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Swoole\Event
Референца за `class.swoole-event.php` со подобрена типографија и навигација.
Класата Swoole\Event
(PECL swoole >= 1.9.0)
Вовед
The Swoole extension provides low-level interfaces to directly manipulate the underlying epoll/kqueue/poll/select event loop. It allows adding sockets created by other extensions or PHP's stream/socket extensions to Swoole's EventLoop.
Забелешка:
The Event module is low-level, being a basic encapsulation of epoll. Users should have experience with IO multiplexing programming.
Event Priority
Signal handler callback functions set via Process::signal
Timer callback functions set via Timer::tick and Timer::after
Deferred execution functions set via Event::defer
Periodic callback functions set via Event::cycle
Swoole Event Socket Type
-
fdint -
File descriptors, including Swoole\Client->$sock, Swoole\Process->$pipe, or any other file descriptor (fd).
-
stream resourceresource -
Resources created by stream_socket_client/fsockopen.
-
socket resourceresource -
Resources created by socket_create from the sockets extension require the --enable-sockets flag during Swoole compilation.
-
objectobject -
Swoole automatically converts Swoole\Process into UnixSocket and Swoole\Client into connected client sockets at the underlying level.
Синопсис на класата
mixed
$sock,callable
$read_callback,callable
$write_callback = ?,int
$flags = ?): bool
$fd, int $events
= SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE
): boolСодржина
- Swoole\Event::add — Add a socket to the underlying reactor event listener
- Swoole\Event::cycle — Define a function to execute at the end of each event loop iteration
- Swoole\Event::defer — Execute a function at the start of the next event loop
- Swoole\Event::del — Remove a socket from reactor event listener
- Swoole\Event::dispatch — Perform a single event loop iteration
- Swoole\Event::isset — Check if a socket is being monitored in the event loop
- Swoole\Event::set — Modify event listener callbacks and mask
- Swoole\Event::wait — Start event loop
- Swoole\Event::write — Write data to socket asynchronously