Menu
Reference
- Manticore\Ds
- Async
- Http
- Http\WebSocket
- Buffer
- Process
- Io\Poll
- Interfaces
- Handle
- Classes
- BackendUnavailableException
- Context
- FailedContextInitializationException
- FailedHandleAddException
- FailedPollOperationException
- FailedPollWaitException
- FailedWatcherModificationException
- HandleAlreadyWatchedException
- InactiveWatcherException
- InvalidHandleException
- PollException
- Watcher
- Enums
- Backend
- Event
- Manticore\Sapi
- Ffi
Watcher
final class Watcher
A registration of one handle in a {@see Context}.
Created by {@see Context::add}. It records which events are watched, which fired in the last Context::wait(), and the data attached when it was added. After remove() the watcher is inactive and its modifying methods throw {@see InactiveWatcherException}.
Methods
getHandle() | The watched handle. |
getWatchedEvents() | The events this watcher currently asks for. |
getTriggeredEvents() | The events reported for this watcher by the last Context::wait(). |
getData() | The user data attached to this watcher. |
hasTriggered() | Whether the given event was reported by the last Context::wait(). |
isActive() | Whether the watcher is still registered in its context. |
modify() | Replace the watched events and the attached data. |
modifyEvents() | Replace the watched events, keeping the attached data. |
modifyData() | Replace the attached data, keeping the watched events. |
remove() | Stop watching the handle and deactivate the watcher. |
forget() | Deactivate the watcher without unregistering the handle from the kernel. |
getHandle()#source
function getHandle(): Handle
The watched handle.
Returns
Handle — the handle given to Context::add()
getWatchedEvents()#source
function getWatchedEvents(): array
The events this watcher currently asks for.
Returns
Event[] — the watched events
getTriggeredEvents()#source
function getTriggeredEvents(): array
The events reported for this watcher by the last Context::wait().
Returns
Event[] — the triggered events; empty if it was not ready
getData()#source
function getData(): mixed
The user data attached to this watcher.
Returns
mixed — the $data given to Context::add() or modify()
hasTriggered()#source
function hasTriggered(Event $event): bool
Whether the given event was reported by the last Context::wait().
Parameters
$eventEvent- the event to test
Returns
bool — true if it fired
isActive()#source
function isActive(): bool
Whether the watcher is still registered in its context.
Returns
bool — false after remove() or forget()
modify()#source
function modify(array $events, mixed $data = null): void
Replace the watched events and the attached data.
Parameters
$eventsEvent[]- the new events
$datamixed = null- the new user data (null clears it)
Throws
- InactiveWatcherException
- if the watcher was removed
modifyEvents()#source
function modifyEvents(array $events): void
Replace the watched events, keeping the attached data.
Parameters
$eventsEvent[]- the new events
Throws
- InactiveWatcherException
- if the watcher was removed
modifyData()#source
function modifyData(mixed $data): void
Replace the attached data, keeping the watched events.
Parameters
$datamixed- the new user data
Throws
- InactiveWatcherException
- if the watcher was removed
remove()#source
function remove(): void
Stop watching the handle and deactivate the watcher.
Throws
- InactiveWatcherException
- if the watcher was already removed
forget()#source
function forget(): void
Deactivate the watcher without unregistering the handle from the kernel.
Use it in a forked child for a registration the parent owns: a child shares the parent's epoll instance, where unregistering would stop the parent watching the handle too.
Throws
- InactiveWatcherException
- if the watcher was already removed