# del
~~~
boolean \Warriorman\Lib\Timer::del(int $timer_id)
~~~
删除某个定时器
### 参数
`timer_id`
定时器的id,即add接口返回的整型
### 返回值
boolean
### 示例
~~~
use \Workerman\Worker;
use \Workerman\Lib\Timer;
require_once __DIR__ . '/Workerman/Autoloader.php';
Warriorman\Worker::rename();
$task= new Worker("tcp://0.0.0.0:2345");
$task->protocol = "\Workerman\Protocols\Http";
// 开启多少个进程运行定时任务,注意多进程并发问题
$task->count = 1;
$task->onWorkerStart = function($task)
{
// 每2秒运行一次
$timer_id = Timer::add(2, function()
{
echo "task run\n";
});
// 20秒后运行一个一次性任务,删除2秒一次的定时任务
Timer::add(20, function($timer_id)
{
Timer::del($timer_id);
}, array($timer_id), false);
};
// 运行worker
Worker::runAll();
~~~
- 序言
- 启动停止
- 简单的开发示例
- 性能测试
- 性能测试-数据库
- 通讯协议
- Coroutine类
- create
- getCid
- yield
- resume
- sleep
- wait
- getTotalNum
- isExist
- defer
- Runtime类
- Worker类
- 构造函数
- 属性
- workerId
- id
- name
- protocol
- transport
- reusePort
- backlog
- connections
- stdoutFile
- pidFile
- logFile
- user
- reloadable
- daemonize
- globalEvent
- 回调属性
- onWorkerStart
- onWorkerReload
- onConnect
- onMessage
- onClose
- onBufferFull
- onBufferDrain
- onError
- 方法
- rename
- runAll
- stopAll
- listen
- TcpConnection类
- 属性
- id
- protocol
- worker
- maxSendBufferSize
- defaultMaxSendBufferSize
- defaultMaxPackageSize
- 方法
- set
- send
- getRemoteIp
- getRemotePort
- close
- destroy
- pauseRecv
- resumeRecv
- pipe
- Timer定时器类
- add
- del
- 定时器注意事项
- Channel类
- 构造方法
- push
- pop
- length
- isEmpty()