mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-29 23:38:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@335484 c90b9560-bf6c-de11-be94-00142212c4b1
173 lines
3.8 KiB
XML
173 lines
3.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<chapter xml:id="event.callbacks" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<title>Event callbacks</title>
|
|
<para>
|
|
If a callback is registered for an event, it will be called when the event
|
|
becomes active. To associate a callback with event one can pass a
|
|
<type>callable</type>
|
|
to either
|
|
<methodname>Event::__construct</methodname>
|
|
, or
|
|
<methodname>Event::set</methodname>
|
|
, or one of the factory methods like
|
|
<methodname>Event::timer</methodname>
|
|
.
|
|
</para>
|
|
<para>
|
|
An event callback should match the following prototype:
|
|
</para>
|
|
<methodsynopsis>
|
|
<type>void</type>
|
|
<methodname>callback</methodname>
|
|
<methodparam
|
|
choice="opt">
|
|
<type>mixed</type>
|
|
<parameter>fd</parameter>
|
|
<initializer>&null;</initializer>
|
|
</methodparam>
|
|
<methodparam
|
|
choice="opt">
|
|
<type>int</type>
|
|
<parameter>what</parameter>
|
|
</methodparam>
|
|
<methodparam
|
|
choice="opt">
|
|
<type>mixed</type>
|
|
<parameter>arg</parameter>
|
|
<initializer>&null;</initializer>
|
|
</methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>fd</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
The file descriptor, stream resource or socket associated with the
|
|
event. For signal event
|
|
<parameter>fd</parameter>
|
|
is equal to the signal number.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>what</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
Bit mask of
|
|
<emphasis>all</emphasis>
|
|
events triggered.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>arg</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
User custom data.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
<para>
|
|
<methodname>Event::timer</methodname>
|
|
expects the callback to match the following prototype:
|
|
</para>
|
|
<methodsynopsis>
|
|
<type>void</type>
|
|
<methodname>callback</methodname>
|
|
<methodparam
|
|
choice="opt">
|
|
<type>mixed</type>
|
|
<parameter>arg</parameter>
|
|
<initializer>&null;</initializer>
|
|
</methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>arg</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
User custom data.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
<para>
|
|
<methodname>Event::signal</methodname>
|
|
expects the callback to match the following prototype:
|
|
</para>
|
|
<methodsynopsis>
|
|
<type>void</type>
|
|
<methodname>callback</methodname>
|
|
<methodparam
|
|
choice="opt">
|
|
<type>int</type>
|
|
<parameter>signum</parameter>
|
|
</methodparam>
|
|
<methodparam
|
|
choice="opt">
|
|
<type>mixed</type>
|
|
<parameter>arg</parameter>
|
|
<initializer>&null;</initializer>
|
|
</methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>signum</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
The number of the triggered signal(e.g.
|
|
<constant>SIGTERM</constant>
|
|
).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<parameter>arg</parameter>
|
|
</term>
|
|
<listitem>
|
|
<para>
|
|
User custom data.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</chapter>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|