|
4 | 4 | <refentry xml:id="swoole-timer.after" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
5 | 5 | <refnamediv>
|
6 | 6 | <refname>Swoole\Timer::after</refname>
|
7 |
| - <refpurpose>Trigger a callback function after a period of time.</refpurpose> |
| 7 | + <refpurpose>Execute a function after specified time.</refpurpose> |
8 | 8 | </refnamediv>
|
9 | 9 |
|
10 | 10 | <refsect1 role="description">
|
11 | 11 | &reftitle.description;
|
12 | 12 | <methodsynopsis>
|
13 |
| - <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Swoole\Timer::after</methodname> |
14 |
| - <methodparam><type>int</type><parameter>after_time_ms</parameter></methodparam> |
15 |
| - <methodparam><type>callable</type><parameter>callback</parameter></methodparam> |
| 13 | + <modifier>public</modifier> <modifier>static</modifier> <type>int</type><methodname>Swoole\Timer::after</methodname> |
| 14 | + <methodparam><type>int</type><parameter>msec</parameter></methodparam> |
| 15 | + <methodparam><type>callable</type><parameter>callback_function</parameter></methodparam> |
| 16 | + <methodparam rep="repeat"><type>mixed</type><parameter>params</parameter></methodparam> |
16 | 17 | </methodsynopsis>
|
17 | 18 | <para>
|
18 |
| - Trigger a callback function after a period of time. |
| 19 | + Execute a function after a specified time. The Swoole\Timer::after function is a one-time timer that will be |
| 20 | + destroyed once executed. |
19 | 21 | </para>
|
20 |
| - |
21 | 22 | </refsect1>
|
22 | 23 |
|
23 | 24 | <refsect1 role="parameters">
|
24 | 25 | &reftitle.parameters;
|
25 | 26 | <variablelist>
|
26 | 27 | <varlistentry>
|
27 |
| - <term><parameter>after_time_ms</parameter></term> |
| 28 | + <term><parameter>msec</parameter></term> |
28 | 29 | <listitem>
|
29 | 30 | <para>
|
30 |
| - |
| 31 | + Specified time in milliseconds (e.g. 1000 means 1 second). |
31 | 32 | </para>
|
32 | 33 | </listitem>
|
33 | 34 | </varlistentry>
|
34 | 35 | <varlistentry>
|
35 |
| - <term><parameter>callback</parameter></term> |
| 36 | + <term><parameter>callback_function</parameter></term> |
36 | 37 | <listitem>
|
37 | 38 | <para>
|
38 |
| - |
| 39 | + The callback function to be executed when timer expires. |
| 40 | + </para> |
| 41 | + </listitem> |
| 42 | + </varlistentry> |
| 43 | + <varlistentry> |
| 44 | + <term><parameter>params</parameter></term> |
| 45 | + <listitem> |
| 46 | + <para> |
| 47 | + Additional parameters to pass to the callback function. |
39 | 48 | </para>
|
40 | 49 | </listitem>
|
41 | 50 | </varlistentry>
|
|
45 | 54 | <refsect1 role="returnvalues">
|
46 | 55 | &reftitle.returnvalues;
|
47 | 56 | <para>
|
48 |
| - |
| 57 | + Returns timer ID which can be used to clear the timer. |
49 | 58 | </para>
|
50 | 59 | </refsect1>
|
51 | 60 |
|
52 |
| - |
| 61 | + <refsect1 role="examples"> |
| 62 | + &reftitle.examples; |
| 63 | + <para> |
| 64 | + <example> |
| 65 | + <title><function>Swoole\Timer::after</function> example</title> |
| 66 | + <programlisting role="php"> |
| 67 | + <![CDATA[ |
| 68 | +<?php |
| 69 | +$str = "Swoole"; |
| 70 | +Swoole\Timer::after(1000, function() use ($str) { |
| 71 | + echo "Hello, $str\n"; |
| 72 | +}); |
| 73 | +?> |
| 74 | +]]> |
| 75 | + </programlisting> |
| 76 | + </example> |
| 77 | + </para> |
| 78 | + </refsect1> |
53 | 79 | </refentry>
|
54 | 80 |
|
55 | 81 | <!-- Keep this comment at the end of the file
|
|
0 commit comments