Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127475 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 6A1391A00BC for ; Tue, 27 May 2025 07:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748331391; bh=RBTkfrb9KkEjqOdrBz9QOcmbCjg26uNc/xi/qXhJ7lA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ybj9hFdcHZ7yGmQ9LPAWq5aXBFX2DOZFeU9bxRtiu0rwHe4MvXzQP1E0aVtqysSfM TrcGBbbJsubOsTDtmPwH1iIdWCdhGF+cbZfH6ngIskvC0icOSpCmoz1sV2pBae3YY6 pLzZYNi4wBg1L843a2EfQbPIhKOMV3xSopwZpmMBX46yBOTwyjvuqFn/JDyLOQFn9d dsGJSIQyqBul6cDVq2aGTMz4ttpr0aeawk4qZKAB20HeFgnMAihCorybuK5bLTFsy+ ErklyE40TS94XQcv9lJNFTwCJSr7BuGSOytv3pgROE/aMWpOtYHg5krbd+9dT6/0su XK9QnsM+GcbpA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0BBCC180051 for ; Tue, 27 May 2025 07:36:30 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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, 27 May 2025 07:36:29 +0000 (UTC) Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 0486AC653EE for ; Tue, 27 May 2025 07:38:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1D1B560654 for ; Tue, 27 May 2025 07:38:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EE6F31C22DAA2 for ; Tue, 27 May 2025 09:38:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chilliet.eu; s=dkim; t=1748331514; h=from:subject:date:message-id:to:mime-version:content-type:in-reply-to: references; bh=RBTkfrb9KkEjqOdrBz9QOcmbCjg26uNc/xi/qXhJ7lA=; b=AtJOHbYzdoaUPRiR8lWHJwx+Hic2atnJ5HYDUHXtWSCpfAYqrDUzRdj7nBBoJK4HHKbd6O 4CmRjIqdoQwZUyHe026jHjNquMB85G3kzm/O0RsjawFbVDW3rkiLpYXjGbZD/ujWgJU3aD Vqz9gDGGFLINU0oNYoWx3Y9KEv1ZFF/wlBXKx/pCuUdXVR6uldHkWfk6eM1Dr95bX7j0cT gsd6tyYUZPqh/KgKT3eb9Fm21F5NXw40U3Qtbwm6xtVstRdEQhHbNKyELixzNudPa3n7ov 0LFkz9bInCwYhxTtpRlOwpNGc1EZ4ZOXdM/HUpmr8rM8vXX/++n7cat9mly/LQ== To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Add num_available_processors Date: Tue, 27 May 2025 09:38:22 +0200 Message-ID: <6208340.lOV4Wx5bFT@come-prox15amd> In-Reply-To: <8b76a3d4-4583-4849-a75f-00f645191247@gmail.com> References: <8b76a3d4-4583-4849-a75f-00f645191247@gmail.com> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5061789.31r3eYUQgx"; micalg="pgp-sha512"; protocol="application/pgp-signature" X-Last-TLS-Session-Version: TLSv1.3 From: come@chilliet.eu (=?UTF-8?B?Q8O0bWU=?= Chilliet) --nextPart5061789.31r3eYUQgx Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: =?UTF-8?B?Q8O0bWU=?= Chilliet To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Add num_available_processors Date: Tue, 27 May 2025 09:38:22 +0200 Message-ID: <6208340.lOV4Wx5bFT@come-prox15amd> In-Reply-To: <8b76a3d4-4583-4849-a75f-00f645191247@gmail.com> MIME-Version: 1.0 Le samedi 24 mai 2025, 19:42:34 heure d=E2=80=99=C3=A9t=C3=A9 d=E2=80=99Eur= ope centrale Niels Dossche a =C3=A9crit : > In my opinion, the return type should not be nullable. > Returning NULL when the platform (or PHP on that platform) doesn't suppor= t getting this information is an anti-pattern. > Instead, availability of the necessary functionality should be checked at= configure time and the function should be made conditionally available. > That way, the return type can just be "int". I strongly disagree here, having PHP function not always available is a mes= s, and forces function_exists checks all over the code. It feels archaic. I get the idea of throwing instead of returning NULL for errors, but the id= ea behind the nullable return is to get this nice thing: $cpus =3D num_available_cpus() ?? 1; If the function throws on error, this gets more convoluted. Maybe it can be= replaced by a parameter $defaultNumber and only throw when no default is g= iven? Regarding the CPUs available for PHP or total number discussion, maybe that= justifies the "available" keyword in the name and it returns only those av= ailable to PHP, and we add a second function for total number? Or as some people suggested in the PR, we add a namespaced class with metho= ds for this. C=C3=B4me --nextPart5061789.31r3eYUQgx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEE8x20ac73tsA2u7cuwRZWc8b9+7kFAmg1a+8ACgkQwRZWc8b9 +7kl4Af+PHpx1Ts1agWg6RwNB2p76Zs0ir4wUg/psgGbHwwFK93MOSRrZOM3b3co KhYFJ9f2NmnQgf48PE8JYz7PpAPj4KHgTdH/jY97GaYbmmKjgtz7Tw6OvKHznuVW PXGMixTYjytqY2+cJCYV5K/iIOQHSErBYiT/QXn0bQ+/l3C0/b3XlwgdKXMJRTUE VMlOi4w9+MrUfwd2yJSY1mqdofBNUbWsKSVMIUTW7mxb69615CTvpJ5K0D6xloj6 VFSQ/FdtKX+J9VjF53GwrFnw1nTyu9rqAxvy5Lr/lFk5eoe/UndkCk4DoyUw2K/5 Iw/QqOqeqr8ZuFLTzslTSYEEmVfyoQ== =6cS+ -----END PGP SIGNATURE----- --nextPart5061789.31r3eYUQgx--