Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129572 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id CE0081A00BC for ; Tue, 9 Dec 2025 11:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765280897; bh=LNrK6EHuqksnCR75MZRKTdctLLCrV8Tm0MzqLAgc3wY=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=F+ZqlhBI6pyytCAe0FgWWJLe+ixF0b7b576qCYZccgTTFei3SkKmbzyuR0IrTp+6c DsF5Ev1eLisFvRrI7+luNuSJ9zyvfbjzFnEccmWg9qO7WkaBuWxwOJHJEWDxsLtXh/ 0u0LwT0Auocb2Pw6vR3YaueCTnry7H2y5MBs0vhSgb7kr2j8AEEStUstAAyQvlApkW EcfH+0zAl16Tlg+YJ4rqOlyTWSbCDUAyGcDdnTAncBNpZmeu+EANepPrpOystxAOOr GNY+zsSDPNfILmNR5Tcc3zT2kzt/4nUZ93g2MY42a4cgLcUZ6cLsVEbAIfHXOsk0NL c0LsLzvPJVUxA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4FD22180056 for ; Tue, 9 Dec 2025 11:48:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 9 Dec 2025 11:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1765280889; bh=LNrK6EHuqksnCR75MZRKTdctLLCrV8Tm0MzqLAgc3wY=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=HsguJkk7KMY+I87pVi/BrN2HHb1bZFOC1EV8wbi1Lq+XFqhFMUwOlea1JMI0FZnGO F70C8RCMyjRzaKjffuuDdC8/7StZ7F1Z6aiNEeqpH8DFf+XUDKaAPoYntEBpEuVU1q sK9zVgaFyasAOiqG9f7J9Q1iWfy3eygm0n2wK1cpt+D29+Fd1uSq8O5Y9yYBtZ/ng+ PHCAHhmMwLDGwoI0kXsAmgqjdXdtb66ix7lvbai5vxxigIb7RkUKgzJVupZ/+sEKzd WC+JuJWXrdvsFc2CWNSv4vq8zcr1/PjPQ//E6XB3/v1+0MsboM73noWqScRKG5naQf Rv985dYK9ozRQ== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 864C010C07D; Tue, 09 Dec 2025 11:48:09 +0000 (GMT) Date: Tue, 9 Dec 2025 11:48:09 +0000 (GMT) To: Jakub Zelenka cc: PHP internals list Subject: Re: [PHP-DEV] [RFC] Polling API In-Reply-To: Message-ID: References: Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII From: derick@php.net (Derick Rethans) On Thu, 30 Oct 2025, Jakub Zelenka wrote: > I would like to introduce a new polling API RFC that is part of my > stream evolution work: > > https://wiki.php.net/rfc/poll_api Under "Event Constants", I realised that we can't use enums for this due to them needing to be OR'ed, but it would be nice if at some point in the future we had a way of doing: PollEvent::Read | PollEvent::Write; The enum PollBackend (not sure if that needs to be a backed enum), but this can not stand: case EventPorts = "eventport"; All the others have the case name and value the same, but this one misses the 's'. /** * Remove this watcher from the poll context * * After removal, the watcher becomes inactive and cannot be reused. */ public function remove(): void {} Wouldn't this leave the PollWatcher object as a zombie: ie, it exists, but you can't do anything with it. Would it be possible to move this API somewhere else, so that the memory manager can just destruct it and release the object? * @param int $maxEvents Maximum number of events to return (-1 for unlimited) * @return array Array of PollWatcher instances that have triggered events * @throws PollException If the wait operation fails */ public function wait(int $timeout = -1, int $maxEvents = -1): array {} I am not sure if I like this returning an array. Would it perhaps be better to always return 1 (or 0 in case of non-blocking) events, which allows typing the return value as ?PollWatcher? Alternative, perhaps this can be split up into two methods, wait() and waitMultiple() to be able to handle both approaches? Under "Future Scope", you have (for example) TimerHandle, but as that will (have to) extend PollHandle, it makes little sense to have a getFileDescriptor() method on PollHandle. Perhaps there should be another (abstract) class, so that you can have: - PollHandle - FileDescriptorPollHandle - StreamPollHandle - SocketPollHandle - CurlPollHandle - TimerPollHandle - SignalPollHandle The only other concern I have is that some polling backends allow for different events to be watched, which makes it harder to write portable code. cheers, Derick -- https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support mastodon: @derickr@phpc.social @xdebug@phpc.social