mirror of
https://github.com/danog/amp.git
synced 2024-11-26 20:15:00 +01:00
Reactor instance now passed to event callbacks
This commit is contained in:
parent
f2b837ba19
commit
7eccb0cc5c
@ -1,3 +1,8 @@
|
||||
#### master
|
||||
|
||||
- Timed event callbacks now passed the reactor instance at param 2 upon invocation
|
||||
- IO callbacks now passed the reactor instance at param 3 upon invocation
|
||||
|
||||
v0.2.0
|
||||
------
|
||||
|
||||
|
@ -77,7 +77,7 @@ class LibeventReactor implements Reactor, Forkable {
|
||||
|
||||
$wrapper = function() use ($callback, $watcherId) {
|
||||
try {
|
||||
$callback($watcherId);
|
||||
$callback($watcherId, $this);
|
||||
$this->cancel($watcherId);
|
||||
} catch (\Exception $e) {
|
||||
$this->stopException = $e;
|
||||
@ -101,7 +101,7 @@ class LibeventReactor implements Reactor, Forkable {
|
||||
|
||||
$wrapper = function() use ($callback, $event, $interval, $watcherId) {
|
||||
try {
|
||||
$callback($watcherId);
|
||||
$callback($watcherId, $this);
|
||||
event_add($event, $interval);
|
||||
} catch (\Exception $e) {
|
||||
$this->stopException = $e;
|
||||
@ -132,7 +132,7 @@ class LibeventReactor implements Reactor, Forkable {
|
||||
|
||||
$wrapper = function($stream) use ($callback, $watcherId) {
|
||||
try {
|
||||
$callback($watcherId, $stream);
|
||||
$callback($watcherId, $stream, $this);
|
||||
} catch (\Exception $e) {
|
||||
$this->stopException = $e;
|
||||
$this->stop();
|
||||
|
@ -91,13 +91,13 @@ class NativeReactor implements Reactor {
|
||||
foreach ($r as $readableStream) {
|
||||
$streamId = (int) $readableStream;
|
||||
foreach ($this->readCallbacks[$streamId] as $watcherId => $callback) {
|
||||
$callback($watcherId, $readableStream);
|
||||
$callback($watcherId, $readableStream, $this);
|
||||
}
|
||||
}
|
||||
foreach ($w as $writableStream) {
|
||||
$streamId = (int) $writableStream;
|
||||
foreach ($this->writeCallbacks[$streamId] as $watcherId => $callback) {
|
||||
$callback($watcherId, $writableStream);
|
||||
$callback($watcherId, $writableStream, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ class NativeReactor implements Reactor {
|
||||
);
|
||||
}
|
||||
|
||||
$callback($watcherId);
|
||||
$callback($watcherId, $this);
|
||||
}
|
||||
|
||||
function at(callable $callback, $timeString) {
|
||||
|
Loading…
Reference in New Issue
Block a user