php8.5
Home/ Manual/ pcntl / functions/ pcntl_setqos_class

pcntl_setqos_class

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Set the QoS class of the current thread

Description

pcntl_setqos_class(Pcntl\QosClass $qos_class = Pcntl\QosClass::Default): void

Sets the Quality of Service (QoS) class of the current thread.

Parameters

qos_class

The Quality of Service class to assign to the current thread. The operating system uses this as a hint to schedule CPU time, I/O priority, and energy usage, with higher classes preempting lower ones. See Pcntl\QosClass for the available cases.

Pcntl\QosClass::UserInteractive

Highest priority. Intended for work that directly drives a user interface and must complete virtually instantly to avoid perceived delay, such as event handling or drawing.

Pcntl\QosClass::UserInitiated

High priority, just below UserInteractive. Intended for work the user has explicitly initiated and is actively waiting on, expected to complete within a few seconds.

Pcntl\QosClass::Default

Standard priority, used when no more specific class applies. Runs after higher-priority work but ahead of Utility and Background.

Pcntl\QosClass::Utility

Lower priority, intended for long-running work the user is aware of but not actively waiting on, such as downloads, imports, or bulk computation. Scheduled in an energy-efficient manner.

Pcntl\QosClass::Background

Lowest priority, intended for work the user is not aware of, such as prefetching, indexing, or maintenance. Heavily optimized for energy efficiency and may be deferred when the system is under load.

Note

This function is only available on Apple platforms.

Return Values

Void

Errors/Exceptions

Throws an Error if the underlying call to pthread_set_qos_class_self_np() fails.

See Also

Source: reference/pcntl/functions/pcntl-setqos-class.xml · from the official PHP manual (php/doc-en)