Swoole\Timer::set

Declaration

<?php
Swoole\Timer::set(array $timerSettings)\:\ void

Parameters

timerSettings
  • enable_coroutine => true: Enable coroutine support within a timer callable

Return

success

if successful, it returns true

false

if the operation failed, it returns false

Description

Set the runtime settings for Timer callables. The settings can be accessed by Swoole\Timer::setting.

Example

<?php

Swoole\Timer::set([
  'enable_coroutine' => true,
]);

var_dump(Swoole\Timer::setting);

Enable Coroutine Support

You can use the set method to enable full coroutine support within a timer context, it will automatically create a coroutine context for you so you don't need to create the initial go() context when a timer runs.