-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
50 lines (43 loc) · 1.48 KB
/
bootstrap.php
File metadata and controls
50 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
use function Onion\Framework\Loop\{scheduler, register_default_signal_handler};
if (!defined('EVENT_LOOP_AUTOSTART')) {
/**
* Should the event loop auto-start or would require explicit
* trigger by the user. Defaults to `true`
*
* @var bool `true` to enable, `false` otherwise
*/
define('EVENT_LOOP_AUTOSTART', true);
}
if (!defined('EVENT_LOOP_DEFAULT_HANDLE_SIGNALS')) {
/**
* Use internal signal handler that is aware of the event
* loop. Defaults to `true`
*
* @var bool `true` to enable, `false` otherwise
*/
define('EVENT_LOOP_DEFAULT_HANDLE_SIGNALS', false);
}
if (!defined('EVENT_LOOP_STREAM_IDLE_TIMEOUT')) {
/**
* A default timeout block the event loop if there are no tasks
* or timers pending, specifically in situations where the server
* is waiting for connections, etc. This would allow near instant
* scheduling (based on the `EVENT_LOOP_STREAM_IDLE_TIMEOUT`, with
* the default 1s it'd be as close as ~1s correct trigger).
*
* An obvious candidate would be implementation of a cron-like
* functionality without leaving the application scope.
*
* Defaults to 1s
* @var int timeout in microseconds.
*/
define('EVENT_LOOP_STREAM_IDLE_TIMEOUT', 1_000_000);
}
if (EVENT_LOOP_DEFAULT_HANDLE_SIGNALS) {
register_default_signal_handler();
}
if (EVENT_LOOP_AUTOSTART) {
register_shutdown_function(fn () => scheduler()->start());
}