xp_priority

xp_priority($priority, $process)

Sets the priority of a process.

This allows for controlling the order of processes rather than using FIFO.

Priority uses an ascending order where 0 > 1.

Processes registered with a high priority will be executed before those with a low or default priority.

Process priority is handy when multiple process will execute and their order is important.

Note

This is different from an interrupt.

Installed interrupts will still be executed before or after a prioritized process.

Parameters:
  • integer – Priority to assign
  • callable|process – PHP Callable or XPSPLProcess.
Return type:

object Process

Example #1 Basic Usage

This installs multiple process each with a seperate ascending priority.

<?php

xp_signal(XP_SIG('foo'), priority(0, function(){
    echo 'foo';
}));

xp_signal(XP_SIG('foo'), priority(3, function(){
    echo 'bar';
}));

xp_signal(XP_SIG('foo'), priority(5, function(){
    echo 'hello';
}));

xp_signal(XP_SIG('foo'), priority(10, function(){
    echo 'world';
}));

The above code will output.

foobarhelloworld
Read the Docs v: v5.0.1
Versions
latest
v5.0.1
v5.0.0
v4.0.1
v4.0.0
v3.1.1
v3.1.0
v3.0.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.