Swoole\Coroutine::set (array $settings)

Declaration

<?php
Swoole\Coroutine::set (array $settings)

Parameters

settings
[
    'max_coroutine' => 4096,
    'c_stack_size' => 2 * 1024 * 1024,
    'socket_connect_timeout' => 1,
    'socket_timeout' => -1,
    'socket_read_timeout' => -1,
    'socket_write_timeout' => -1,
    'log_level' => SWOOLE_LOG_INFO | SWOOLE_LOG_DEBUG | SWOOLE_LOG_TRACE | SWOOLE_LOG_NOTICE | SWOOLE_LOG_WARNING | SWOOLE_LOG_ERROR,
    'hook_flags' => HOOK_FLAGS,
    'trace_flags' => '',
    'dns_cache_expire' => 60,
    'dns_cache_capacity' => 1000,
    'dns_server' => '8.8.8.8',
    'display_errors' => '',
    'aio_core_worker_num' => 10,
    'aio_worker_num' => 10,
    'aio_max_wait_time' => 1,
    'aio_max_idle_time' => 1,
    'exit_condition' => function() {
        return Swoole\Coroutine::stats()['coroutine_num'] === 0;
    } // Since version 4.5.0
]```

Return

Description

Update the settings of the coroutines.

Example

<?php
$option = [
    'max_coroutine' => 4096,
    'c_stack_size' => 2 * 1024 * 1024,
    'socket_connect_timeout' => 1,
    'socket_timeout' => -1,
    'socket_read_timeout' => -1,
    'socket_write_timeout' => -1,
    'log_level' => SWOOLE_LOG_INFO,
    'hook_flags' => HOOK_FLAGS,
    'trace_flags' => '',
    'dns_cache_expire' => 60,
    'dns_cache_capacity' => 1000,
    'dns_server' => '8.8.8.8',
    'display_errors' => '',
    'aio_core_worker_num' => 10,
    'aio_worker_num' => 10,
    'aio_max_wait_time' => 1,
    'aio_max_idle_time' => 1,
    'exit_condition' => function() {
        return Swoole\Coroutine::stats()['coroutine_num'] === 0;
    } // Since version 4.5.0

];
Swoole\Coroutine::set($option);