optimize swoole event docs - #4774
Conversation
| <para> | ||
| A socket that has already been added cannot be added again. Use swoole_event_set to | ||
| modify the corresponding callback functions and event types for the socket. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| A socket that has already been added cannot be added again. Use swoole_event_set to | |
| modify the corresponding callback functions and event types for the socket. | |
| </para> | |
| <simpara> | |
| A socket that has already been added cannot be added again. Use swoole_event_set to | |
| modify the corresponding callback functions and event types for the socket. | |
| </simpara> |
| <para> | ||
| Defines a callback function to execute at the end (or beginning, if <parameter>before</parameter> is true) of each event loop iteration. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| Defines a callback function to execute at the end (or beginning, if <parameter>before</parameter> is true) of each event loop iteration. | |
| </para> | |
| <simpara> | |
| Defines a callback function to execute at the end (or beginning, if <parameter>before</parameter> is true) of each event loop iteration. | |
| </simpara> |
| <para> | ||
| The function to execute. Set to <literal>null</literal> to clear a previously set cycle function. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| The function to execute. Set to <literal>null</literal> to clear a previously set cycle function. | |
| </para> | |
| <simpara> | |
| The function to execute. Set to <literal>null</literal> to clear a previously set cycle function. | |
| </simpara> |
| <para> | ||
| If <literal>true</literal>, the callback executes before the event loop; if <literal>false</literal>, after. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| If <literal>true</literal>, the callback executes before the event loop; if <literal>false</literal>, after. | |
| </para> | |
| <simpara> | |
| If <literal>true</literal>, the callback executes before the event loop; if <literal>false</literal>, after. | |
| </simpara> |
| <para> | ||
| &return.success; | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| &return.success; | |
| </para> | |
| <simpara> | |
| &return.success; | |
| </simpara> |
| <refsect1 role="description"> | ||
| &reftitle.description; | ||
| <methodsynopsis> | ||
| <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Event::defer</methodname> |
There was a problem hiding this comment.
| <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Event::defer</methodname> | |
| <modifier>public</modifier> <modifier>static</modifier> <type>bool</type><methodname>Swoole\Event::defer</methodname> |
| &reftitle.description; | ||
| <methodsynopsis> | ||
| <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Event::exit</methodname> | ||
| <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Event::dispatch</methodname> |
There was a problem hiding this comment.
| <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Event::dispatch</methodname> | |
| <modifier>public</modifier> <modifier>static</modifier> <type>bool</type><methodname>Swoole\Event::dispatch</methodname> |
| <refsect1 role="description"> | ||
| &reftitle.description; | ||
| <methodsynopsis> | ||
| <modifier>public</modifier> <modifier>static</modifier> <type>bool</type><methodname>Swoole\Event::isset</methodname> |
There was a problem hiding this comment.
| <modifier>public</modifier> <modifier>static</modifier> <type>bool</type><methodname>Swoole\Event::isset</methodname> | |
| <modifier>public</modifier> <modifier>static</modifier> <type>bool</type><methodname>Swoole\Event::isset</methodname> |
| <para> | ||
| Checks whether the specified file descriptor is being monitored for the given event types in the event loop. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| Checks whether the specified file descriptor is being monitored for the given event types in the event loop. | |
| </para> | |
| <simpara> | |
| Checks whether the specified file descriptor is being monitored for the given event types in the event loop. | |
| </simpara> |
| <para> | ||
| Event types to check (bitmask of <constant>SWOOLE_EVENT_READ</constant> and/or <constant>SWOOLE_EVENT_WRITE</constant>). | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| Event types to check (bitmask of <constant>SWOOLE_EVENT_READ</constant> and/or <constant>SWOOLE_EVENT_WRITE</constant>). | |
| </para> | |
| <simpara> | |
| Event types to check (bitmask of <constant>SWOOLE_EVENT_READ</constant> and/or <constant>SWOOLE_EVENT_WRITE</constant>). | |
| </simpara> |
| <para> | ||
| &return.success; | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| &return.success; | |
| </para> | |
| <simpara> | |
| &return.success; | |
| </simpara> |
| <para> | ||
| Swoole automatically converts Swoole\Process into UnixSocket and Swoole\Client | ||
| into connected client sockets at the underlying level. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| Swoole automatically converts Swoole\Process into UnixSocket and Swoole\Client | |
| into connected client sockets at the underlying level. | |
| </para> | |
| <simpara> | |
| Swoole automatically converts Swoole\Process into UnixSocket and Swoole\Client | |
| into connected client sockets at the underlying level. | |
| </simpara> |
| <para> | ||
| Resources created by socket_create from the sockets extension require | ||
| the --enable-sockets flag during Swoole compilation. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| Resources created by socket_create from the sockets extension require | |
| the --enable-sockets flag during Swoole compilation. | |
| </para> | |
| <simpara> | |
| Resources created by socket_create from the sockets extension require | |
| the --enable-sockets flag during Swoole compilation. | |
| </simpara> |
| <para> | ||
| Resources created by stream_socket_client/fsockopen. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| Resources created by stream_socket_client/fsockopen. | |
| </para> | |
| <simpara> | |
| Resources created by stream_socket_client/fsockopen. | |
| </simpara> |
| <para> | ||
| File descriptors, including Swoole\Client->$sock, Swoole\Process->$pipe, or any other file descriptor (fd). | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| File descriptors, including Swoole\Client->$sock, Swoole\Process->$pipe, or any other file descriptor (fd). | |
| </para> | |
| <simpara> | |
| File descriptors, including Swoole\Client->$sock, Swoole\Process->$pipe, or any other file descriptor (fd). | |
| </simpara> |
| <para> | ||
| The Event module is low-level, being a basic encapsulation of epoll. Users should have experience with IO multiplexing programming. | ||
| </para> |
There was a problem hiding this comment.
| <para> | |
| The Event module is low-level, being a basic encapsulation of epoll. Users should have experience with IO multiplexing programming. | |
| </para> | |
| <simpara> | |
| The Event module is low-level, being a basic encapsulation of epoll. Users should have experience with IO multiplexing programming. | |
| </simpara> |
| @@ -12,11 +12,81 @@ | |||
| <section xml:id="swoole-event.intro"> | |||
| &reftitle.intro; | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
|
|
||
| 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. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <para> | ||
|
|
||
| &return.success; | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| @@ -45,11 +69,32 @@ | |||
| <refsect1 role="returnvalues"> | |||
| &reftitle.returnvalues; | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Event::dispatch</methodname> | ||
| <void /> | ||
| </methodsynopsis> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| The purpose of this function is to maintain compatibility with some frameworks. | ||
| When a framework internally manages its own reactor loop, using Event::wait would allow | ||
| Swoole's underlying layer to retain control, preventing the framework from taking over execution. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <methodparam choice="opt"><type>string</type><parameter>events</parameter></methodparam> | ||
| <methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam> | ||
| </methodsynopsis> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| Adds a socket to the underlying reactor event listener. This function can be used in both Server and Client modes. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <term><parameter>events</parameter></term> | ||
| <term><parameter>flags</parameter></term> | ||
| <listitem> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
|
|
||
| Event type mask (e.g. <constant>SWOOLE_EVENT_READ</constant>, <constant>SWOOLE_EVENT_WRITE</constant> | ||
| or <constant>SWOOLE_EVENT_READ</constant> | <constant>SWOOLE_EVENT_WRITE</constant>). | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| @@ -63,11 +68,33 @@ | |||
| <refsect1 role="returnvalues"> | |||
| &reftitle.returnvalues; | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| &return.success; | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <varlistentry> | ||
| <term><parameter>read_callback</parameter></term> | ||
| <listitem> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <varlistentry> | ||
| <term><parameter>write_callback</parameter></term> | ||
| <listitem> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| Callback function for writable events. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <term><parameter>events</parameter></term> | ||
| <term><parameter>flags</parameter></term> | ||
| <listitem> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
|
|
||
| Event type mask (e.g. <constant>SWOOLE_EVENT_READ</constant>, <constant>SWOOLE_EVENT_WRITE</constant> | ||
| or <constant>SWOOLE_EVENT_READ</constant> | <constant>SWOOLE_EVENT_WRITE</constant>). | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| @@ -63,11 +91,9 @@ | |||
| <refsect1 role="returnvalues"> | |||
| &reftitle.returnvalues; | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| &return.success; | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| @@ -14,26 +13,36 @@ | |||
| <void /> | |||
| </methodsynopsis> | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| Starts the event loop. Place this at the end of your PHP program. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
|
|
||
| <refsect1 role="returnvalues"> | ||
| &reftitle.returnvalues; | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| No return value. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <methodparam><type>string</type><parameter>data</parameter></methodparam> | ||
| <modifier>public</modifier> <modifier>static</modifier> <type>bool</type><methodname>Swoole\Event::write</methodname> | ||
| <methodparam><type>mixed</type><parameter>fd</parameter></methodparam> | ||
| <methodparam><type>mixed</type><parameter>data</parameter></methodparam> |
There was a problem hiding this comment.
| <methodparam><type>mixed</type><parameter>data</parameter></methodparam> | |
| <methodparam><type>string</type><parameter>data</parameter></methodparam> |
| <methodparam><type>mixed</type><parameter>fd</parameter></methodparam> | ||
| <methodparam><type>mixed</type><parameter>data</parameter></methodparam> | ||
| </methodsynopsis> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| Makes data sending asynchronous for stream/sockets resources. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| @@ -27,15 +51,15 @@ | |||
| <term><parameter>fd</parameter></term> | |||
| <listitem> | |||
| <para> | |||
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| File descriptor (stream/socket resource, integer, or object). | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <varlistentry> | ||
| <term><parameter>data</parameter></term> | ||
| <listitem> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| Data to send (length must not exceed socket buffer size). | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| <section xml:id="swoole-event.event-priority"> | ||
| <title>Event Priority</title> | ||
| <orderedlist> | ||
| <listitem><para>Signal handler callback functions set via Process::signal</para></listitem> |
There was a problem hiding this comment.
| <listitem><para>Signal handler callback functions set via Process::signal</para></listitem> | |
| <listitem><simpara>Signal handler callback functions set via Process::signal</simpara></listitem> |
| <title>Event Priority</title> | ||
| <orderedlist> | ||
| <listitem><para>Signal handler callback functions set via Process::signal</para></listitem> | ||
| <listitem><para>Timer callback functions set via Timer::tick and Timer::after</para></listitem> |
There was a problem hiding this comment.
| <listitem><para>Timer callback functions set via Timer::tick and Timer::after</para></listitem> | |
| <listitem><simpara>Timer callback functions set via Timer::tick and Timer::after</simpara></listitem> |
| <orderedlist> | ||
| <listitem><para>Signal handler callback functions set via Process::signal</para></listitem> | ||
| <listitem><para>Timer callback functions set via Timer::tick and Timer::after</para></listitem> | ||
| <listitem><para>Deferred execution functions set via Event::defer</para></listitem> |
There was a problem hiding this comment.
| <listitem><para>Deferred execution functions set via Event::defer</para></listitem> | |
| <listitem><simpara>Deferred execution functions set via Event::defer</simpara></listitem> |
| <listitem><para>Signal handler callback functions set via Process::signal</para></listitem> | ||
| <listitem><para>Timer callback functions set via Timer::tick and Timer::after</para></listitem> | ||
| <listitem><para>Deferred execution functions set via Event::defer</para></listitem> | ||
| <listitem><para>Periodic callback functions set via Event::cycle</para></listitem> |
There was a problem hiding this comment.
| <listitem><para>Periodic callback functions set via Event::cycle</para></listitem> | |
| <listitem><simpara>Periodic callback functions set via Event::cycle</simpara></listitem> |
| <methodparam choice="opt"><type>callable</type><parameter>write_callback</parameter></methodparam> | ||
| <methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam> | ||
| </methodsynopsis> | ||
| <para> |
There was a problem hiding this comment.
| <para> | |
| <simpara> |
| <para> | ||
|
|
||
| Modifies the event listener callbacks and mask for the given file descriptor. | ||
| </para> |
There was a problem hiding this comment.
| </para> | |
| </simpara> |
| </varlistentry> | ||
| <varlistentry> | ||
| <term><parameter>events</parameter></term> | ||
| <term><parameter>flags</parameter></term> |
There was a problem hiding this comment.
| <term><parameter>flags</parameter></term> | |
| <term><parameter>events</parameter></term> |
|
Hi @NathanFreeman. Thank you for this PR. I have not looked at the accuracy of the changes, nor have I merged the suggested changes in. I suggest you to have a quick look at those, and present hem in a follow-up PR if required. Over the next few months, we will be migrating this extension to https://github.com/php/doc-extensions per RFC. So any follow-up PRs will likely have to target that repository based on its state. |
No description provided.