mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-07 06:19:48 +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{
|
||||
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
|
||||
//are processed together. It doesn't matter whether they are processed before or after exclusive handlers.
|
||||
if($right->canBeCalledConcurrently()){
|
||||
return $left->canBeCalledConcurrently() ? 0 : 1;
|
||||
}
|
||||
return -1;
|
||||
//Promise::all() can be used more efficiently if concurrent handlers are grouped together.
|
||||
//It's not important whether they are grouped before or after exclusive handlers.
|
||||
return $left->canBeCalledConcurrently() <=> $right->canBeCalledConcurrently();
|
||||
});
|
||||
return $listeners;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user