mirror of
https://github.com/php/doc-ru.git
synced 2026-03-23 23:32:16 +01:00
163 lines
4.4 KiB
XML
163 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: a47dff201e3f65c07f6c84a535951632771cf72d Maintainer: rjhdby Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="event.callbacks">
|
||
<title>Callback-функции</title>
|
||
<para>
|
||
Callback-функция, которую зарегистрировали для события,
|
||
вызывается, когда событие переходит в активный статус. Для привязки к событию
|
||
функцию передают как аргумент параметра
|
||
<type>callable</type>
|
||
в методы <methodname>Event::__construct</methodname>
|
||
или
|
||
<methodname>Event::set</methodname>,
|
||
или в фабричный метод наподобие
|
||
<methodname>Event::timer</methodname>.
|
||
</para>
|
||
<para>
|
||
Функция должна соответствовать следующему прототипу:
|
||
</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>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>fd</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Дескриптор файла, потокового ресурса или сокета, который связан с событием.
|
||
Для событий сигналов
|
||
дескриптор <parameter>fd</parameter>
|
||
совпадает с номером сигнала.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>what</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Побитовая маска
|
||
<emphasis>всех</emphasis>
|
||
обрабатываемых событий.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>arg</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Пользовательские данные.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
<para>
|
||
Для метода
|
||
<methodname>Event::timer</methodname>
|
||
callback-функция должна соответствовать следующему прототипу:
|
||
</para>
|
||
<methodsynopsis>
|
||
<type>void</type>
|
||
<methodname>callback</methodname>
|
||
<methodparam choice="opt">
|
||
<type>mixed</type>
|
||
<parameter>arg</parameter>
|
||
<initializer>&null;</initializer>
|
||
</methodparam>
|
||
</methodsynopsis>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>arg</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Пользовательские данные.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
<para>
|
||
Для метода
|
||
<methodname>Event::signal</methodname>
|
||
callback-функция должна соответствовать следующему прототипу:
|
||
</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>
|
||
<variablelist>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>signum</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Номер сигнала, например
|
||
<constant>SIGTERM</constant>.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
<varlistentry>
|
||
<term>
|
||
<parameter>arg</parameter>
|
||
</term>
|
||
<listitem>
|
||
<para>
|
||
Пользовательские данные.
|
||
</para>
|
||
</listitem>
|
||
</varlistentry>
|
||
</variablelist>
|
||
</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
|
||
-->
|