OpenSwoole\Timer::set

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

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

Parameters

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

Return

success

if successful, it returns true

if the operation failed, it returns false

This method has been deprecated at the version v22.0.0.

Description

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

Example

<?php

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

var_dump(OpenSwoole\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.

Last updated on February 7, 2023