1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 07:42:22 +01:00
Files
archived-doc-ru/reference/ev/evembed/construct.xml
2026-01-18 22:20:57 +00:00

164 lines
5.4 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: b4fbf4434abeca44c58575ff3967e5640f7877d5 Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="evembed.construct">
<refnamediv>
<refname>EvEmbed::__construct</refname>
<refpurpose>Конструктор объекта EvEmbed</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<constructorsynopsis>
<modifier>public</modifier>
<methodname>EvEmbed::__construct</methodname>
<methodparam>
<type>object</type>
<parameter>other</parameter>
</methodparam>
<methodparam choice="opt">
<type>callable</type>
<parameter>callback</parameter>
</methodparam>
<methodparam choice="opt">
<type>mixed</type>
<parameter>data</parameter>
</methodparam>
<methodparam choice="opt">
<type>int</type>
<parameter>priority</parameter>
</methodparam>
</constructorsynopsis>
<simpara>
Это довольно продвинутый тип наблюдателя, который разрешает встроить один цикл
событий в другой. Пока поддерживаются только события ввода-вывода
во встроенном цикле, другие типы наблюдателей иногда обрабатываются с задержкой
или неправильно, и их не рекомендуют использовать.
</simpara>
<simpara>
Подробнее об этом рассказывает страница
<link xlink:href="http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#code_ev_embed_code_when_one_backend_">документации libev</link>.
</simpara>
<simpara>
Этот наблюдатель наиболее полезен
в <emphasis>BSD</emphasis> системах без работающего
<literal>kqueue</literal> для поддержки обработки большого количества сокетов.
Смотрите пример на этой странице.
</simpara>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term>
<parameter>other</parameter>
</term>
<listitem>
<simpara>
Экземпляр класса
<classname>EvLoop</classname>.
Событийный цикл для встраивания. Этот цикл должен быть встраиваемым. Смотрите
описание метода <methodname>Ev::embeddableBackends</methodname>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>callback</parameter>
</term>
<listitem>
<simpara>
Доступные значения параметра описывает страница
«<link linkend="ev.watcher-callbacks">Callback-функции наблюдателей</link>».
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>data</parameter>
</term>
<listitem>
<simpara>
Пользовательские данные, ассоциированные с наблюдателем.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>priority</parameter>
</term>
<listitem>
<simpara>
«<link linkend="ev.constants.watcher-pri">Приоритет наблюдателя</link>».
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Пример встраивания цикла, который создали через kqueue, в событийный цикл по умолчанию</title>
<programlisting role="php">
<![CDATA[
<?php
/*
* Проверьте, доступен ли kqueue, и создайте бэкенд kqueue
* для взаимодействия с сокетами; часто это работает с любой реализацией kqueue.
* Сохраните событийный цикл kqueue/socket-only в loop_socket. Опционально указывают
* флаг EVFLAG_NOENV
*
* Пример взяли из
* http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Examples_CONTENT-9
*/
$loop = EvLoop::defaultLoop();
$socket_loop = NULL;
$embed = NULL;
if (Ev::supportedBackends() & ~Ev::recommendedBackends() & Ev::BACKEND_KQUEUE) {
if (($socket_loop = new EvLoop(Ev::BACKEND_KQUEUE))) {
$embed = new EvEmbed($loop);
}
}
if (!$socket_loop) {
$socket_loop = $loop;
}
// Теперь используйте $socket_loop для каждого сокета, а $loop для всего остального
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member>
<methodname>Ev::embeddableBackends</methodname>
</member>
</simplelist>
</refsect1>
</refentry>
<!-- 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
-->