Php/docs/evwatcher.keepalive

提供:Dev Guides
< Php
2020年12月14日 (月) 12:13時点におけるNotes (トーク | 投稿記録)による版 (autoload)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

EvWatcher::keepalive

(PECL ev >= 0.2.0)

EvWatcher::keepaliveConfigures whether to keep the loop from returning


説明

public EvWatcher::keepalive ([ bool $value ] ) : bool

Configures whether to keep the loop from returning. With keepalive value set to false the watcher won't keep Ev::run() / EvLoop::run() from returning even though the watcher is active.

Watchers have keepalive value true by default.

Clearing keepalive status is useful when returning from Ev::run() / EvLoop::run() just because of the watcher is undesirable. It could be a long running UDP socket watcher or so.


パラメータ

value
With keepalive value set to false the watcher won't keep Ev::run() / EvLoop::run() from returning even though the watcher is active.


返り値

Returns the previous state.


例1 Register an I/O watcher for some UDP socket but do not keep the event loop from running just because of that watcher.

<?php$udp_socket = ...$udp_watcher = new EvIo($udp_socket, Ev::READ, function () { /* ... */ });$udp_watcher->keepalive(FALSE);?>