# push
~~~
Warriorman\Channel->push(mixed $data, float $timeout = -1): bool
~~~
push 数据 【可以是任意类型的 PHP 变量,包括匿名函数和资源】
**说明:**
在通道已满的情况下,`push`会挂起当前协程,在约定的时间内,如果没有任何消费者消费数据,将发生超时,底层会恢复当前协程,`push`调用立即返回`false`,写入失败
### 参数
* **`mixed $data`**
* **功能**:push 数据 【可以是任意类型的 PHP 变量,包括匿名函数和资源】
* **默认值**:无
* **其它值**:无
为避免产生歧义,请勿向通道中写入空数据,如`0`、`false`、`空字符串`、`null`
* **`float $timeout`**
* **功能**:设置超时时间
* **值单位**: 秒【支持浮点型,如`1.5`表示`1s`+`500ms`】
* **默认值**:`-1`
* **其它值**:无
在通道已满的情况下,`push`会挂起当前
- 序言
- 启动停止
- 简单的开发示例
- 性能测试
- 性能测试-数据库
- 通讯协议
- 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()