| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
namespace AWS\CRT\IO; |
| 7 |
|
| 8 |
use AWS\CRT\NativeResource as NativeResource; |
| 9 |
use AWS\CRT\Options as Options; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
final class EventLoopGroup extends NativeResource { |
| 19 |
|
| 20 |
static function defaults() { |
| 21 |
return [ |
| 22 |
'max_threads' => 0, |
| 23 |
]; |
| 24 |
} |
| 25 |
|
| 26 |
function __construct(array $options = []) { |
| 27 |
parent::__construct(); |
| 28 |
$options = new Options($options, self::defaults()); |
| 29 |
$elg_options = self::$crt->event_loop_group_options_new(); |
| 30 |
self::$crt->event_loop_group_options_set_max_threads($elg_options, $options->getInt('max_threads')); |
| 31 |
$this->acquire(self::$crt->event_loop_group_new($elg_options)); |
| 32 |
self::$crt->event_loop_group_options_release($elg_options); |
| 33 |
} |
| 34 |
|
| 35 |
function __destruct() { |
| 36 |
self::$crt->event_loop_group_release($this->release()); |
| 37 |
parent::__destruct(); |
| 38 |
} |
| 39 |
} |