2016-05-19 18:12:35 +02:00
|
|
|
<?php
|
|
|
|
|
2017-04-18 16:38:16 +02:00
|
|
|
namespace Amp\Loop;
|
2016-05-19 18:12:35 +02:00
|
|
|
|
2017-04-13 18:05:59 +02:00
|
|
|
use Amp\Struct;
|
|
|
|
|
2020-03-28 21:55:44 +01:00
|
|
|
/**
|
|
|
|
* @template TValue as (int|resource|null)
|
2020-03-28 22:20:44 +01:00
|
|
|
*
|
|
|
|
* @psalm-suppress MissingConstructor
|
2020-03-28 21:55:44 +01:00
|
|
|
*/
|
2020-10-09 19:37:37 +02:00
|
|
|
final class Watcher
|
2018-06-18 20:00:01 +02:00
|
|
|
{
|
2017-04-13 18:05:59 +02:00
|
|
|
use Struct;
|
|
|
|
|
2020-10-09 19:37:37 +02:00
|
|
|
public const IO = 0b00000011;
|
|
|
|
public const READABLE = 0b00000001;
|
|
|
|
public const WRITABLE = 0b00000010;
|
|
|
|
public const DEFER = 0b00000100;
|
|
|
|
public const TIMER = 0b00011000;
|
|
|
|
public const DELAY = 0b00001000;
|
|
|
|
public const REPEAT = 0b00010000;
|
|
|
|
public const SIGNAL = 0b00100000;
|
2016-05-26 06:09:53 +02:00
|
|
|
|
2020-09-25 05:17:13 +02:00
|
|
|
public int $type;
|
2016-05-26 06:09:53 +02:00
|
|
|
|
2020-09-25 05:17:13 +02:00
|
|
|
public bool $enabled = true;
|
2016-06-03 17:00:29 +02:00
|
|
|
|
2020-09-25 05:17:13 +02:00
|
|
|
public bool $referenced = true;
|
2016-06-03 17:00:29 +02:00
|
|
|
|
2020-09-25 05:17:13 +02:00
|
|
|
public string $id;
|
2016-05-19 18:12:35 +02:00
|
|
|
|
2017-02-17 05:36:32 +01:00
|
|
|
/** @var callable */
|
2016-05-19 18:12:35 +02:00
|
|
|
public $callback;
|
|
|
|
|
|
|
|
/**
|
2016-06-07 07:18:59 +02:00
|
|
|
* Data provided to the watcher callback.
|
|
|
|
*
|
2016-05-19 18:12:35 +02:00
|
|
|
* @var mixed
|
|
|
|
*/
|
|
|
|
public $data;
|
|
|
|
|
|
|
|
/**
|
2017-04-13 18:05:59 +02:00
|
|
|
* Watcher-dependent value storage. Stream for IO watchers, signal number for signal watchers, interval for timers.
|
2016-06-07 07:18:59 +02:00
|
|
|
*
|
2020-03-28 21:55:44 +01:00
|
|
|
* @var resource|int|null
|
|
|
|
* @psalm-var TValue
|
2016-05-19 18:12:35 +02:00
|
|
|
*/
|
2016-05-26 06:09:53 +02:00
|
|
|
public $value;
|
2020-07-14 21:45:35 +02:00
|
|
|
|
2020-09-26 16:53:24 +02:00
|
|
|
/** @var int|null Timer expiration timestamp. */
|
2020-09-25 05:17:13 +02:00
|
|
|
public ?int $expiration = null;
|
2016-05-19 18:12:35 +02:00
|
|
|
}
|