Documentation

SleeperHandler
in package

Manages a Threaded sleeper which can be waited on for notifications. Calls callbacks for attached notifiers when notifications are received from the notifiers.

Table of Contents

$nextSleeperId  : int
$notifiers  : array<string|int, Closure>
$sharedObject  : Threaded
__construct()  : mixed
addNotifier()  : void
processNotifications()  : void
Processes any notifications from notifiers and calls handlers for received notifications.
removeNotifier()  : void
Removes a notifier from the sleeper. Note that this does not prevent the notifier waking the sleeper up - it just stops the notifier getting actions processed from the main thread.
sleepUntil()  : void
Sleeps until the given timestamp. Sleep may be interrupted by notifications, which will be processed before going back to sleep.
sleepUntilNotification()  : void
Blocks until notifications are received, then processes notifications. Will not sleep if notifications are already waiting.
sleep()  : void

Properties

$notifiers

private array<string|int, Closure> $notifiers = []
Tags
phpstan-var

array<int, \Closure() : void>

Methods

__construct()

public __construct() : mixed
Return values
mixed

addNotifier()

public addNotifier(SleeperNotifier $notifier, Closure $handler) : void
Parameters
$notifier : SleeperNotifier
$handler : Closure

Called when the notifier wakes the server up, of the signature function() : void

Tags
phpstan-param

\Closure() : void $handler

Return values
void

processNotifications()

Processes any notifications from notifiers and calls handlers for received notifications.

public processNotifications() : void
Return values
void

removeNotifier()

Removes a notifier from the sleeper. Note that this does not prevent the notifier waking the sleeper up - it just stops the notifier getting actions processed from the main thread.

public removeNotifier(SleeperNotifier $notifier) : void
Parameters
$notifier : SleeperNotifier
Return values
void

sleepUntil()

Sleeps until the given timestamp. Sleep may be interrupted by notifications, which will be processed before going back to sleep.

public sleepUntil(float $unixTime) : void
Parameters
$unixTime : float
Return values
void

sleepUntilNotification()

Blocks until notifications are received, then processes notifications. Will not sleep if notifications are already waiting.

public sleepUntilNotification() : void
Return values
void

sleep()

private sleep(int $timeout) : void
Parameters
$timeout : int
Return values
void

Search results