-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register shutdown function to clear event loop
- Loading branch information
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Revolt\EventLoop; | ||
|
||
\register_shutdown_function(function (): void { | ||
\register_shutdown_function(function (): void { | ||
EventLoop::defer(function (): void { | ||
print 'Shutdown function registered within pre-loop-run shutdown function' . PHP_EOL; | ||
}); | ||
}); | ||
|
||
|
||
EventLoop::defer(function (): void { | ||
print 'Shutdown function registered before EventLoop::run()' . PHP_EOL; | ||
}); | ||
}); | ||
|
||
EventLoop::run(); | ||
|
||
\register_shutdown_function(function (): void { | ||
\register_shutdown_function(function (): void { | ||
EventLoop::defer(function (): void { | ||
print 'Shutdown function registered within post-loop-run shutdown function' . PHP_EOL; | ||
}); | ||
}); | ||
|
||
EventLoop::defer(function (): void { | ||
print 'Shutdown function registered after EventLoop::run()' . PHP_EOL; | ||
}); | ||
}); | ||
|
||
print 'End of script' . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters