首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

EvWatcher::keepalive

(PECL ev >= 0.2.0)

EvWatcher::keepalive — Configures whether to keep the loop from returning

Description

代码语言:javascript
复制
public bool EvWatcher::keepalive ([  bool $value  ] )

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.

Parameters

value

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

Return Values

Returns the previous state.

Examples

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

代码语言:javascript
复制
<?php
$udp_socket?=?...
$udp_watcher?=?new?EvIo($udp_socket,?Ev::READ,?function?()?{?/*?...?*/?});
$udp_watcher->keepalive(FALSE);
?>

← EvWatcher::invoke

EvWatcher::setCallback →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com