mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-07 22:39:43 +00:00
Simplify handler sorting
This commit is contained in:
parent
117026cb83
commit
d2d663b1c9
@ -45,12 +45,9 @@ final class AsyncHandlerListManager extends BaseHandlerListManager{
|
|||||||
*/
|
*/
|
||||||
private static function sortSamePriorityHandlers(array $listeners) : array{
|
private static function sortSamePriorityHandlers(array $listeners) : array{
|
||||||
uasort($listeners, function(AsyncRegisteredListener $left, AsyncRegisteredListener $right) : int{
|
uasort($listeners, function(AsyncRegisteredListener $left, AsyncRegisteredListener $right) : int{
|
||||||
//While the system can handle these in any order, it's better for latency if concurrent handlers
|
//Promise::all() can be used more efficiently if concurrent handlers are grouped together.
|
||||||
//are processed together. It doesn't matter whether they are processed before or after exclusive handlers.
|
//It's not important whether they are grouped before or after exclusive handlers.
|
||||||
if($right->canBeCalledConcurrently()){
|
return $left->canBeCalledConcurrently() <=> $right->canBeCalledConcurrently();
|
||||||
return $left->canBeCalledConcurrently() ? 0 : 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
});
|
||||||
return $listeners;
|
return $listeners;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user