Swoole\Timer::clearAll

Declaration

<?php
Swoole\Timer::clearAll()\:\ bool

Parameters

none

Return

success

if success, it returns true

fail

if it fails false will be returned

Description

Clear all the current timers within the same process space.

Basically the same as Swoole\Timer::clear but it clears all active timers at once.

Swoole >= v4.4.0 is required

Example

<?php

Swoole\Timer::tick(3000, function () {
    echo "after 3000ms.\n";
});

$str = "Swoole";
Swoole\Timer::after(5000, function() use ($str) {
    echo "Hello, $str\n";
});

// Stop all timers
Swoole\Timer::clearAll();