略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: EvWatcher::keepalive

2024-05-01

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_socketEv::READ, function () { /* ... */ });
$udp_watcher->keepalive(FALSE);
?>
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/evwatcher.keepalive.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3