# push
~~~
Warriorman\Channel->push(mixed $data, float $timeout = -1): bool
~~~
从通道中读取数据。
### 参数
* **`float $timeout`**
* **功能**:设置超时时间
* **值单位**: 秒【支持浮点型,如`1.5`表示`1s`+`500ms`】
* **默认值**:-1 永不超时
* **其它值**:无
### 返回值
* 返回值可以是任意类型的 PHP 变量,包括匿名函数和资源
* 通道被关闭时,执行失败返回`false`
* **通道已满**
* `pop`消费数据后,将自动唤醒其中一个生产者协程,让其写入新数据
* 多个生产者协程同时`push`时,底层自动进行排队,按照顺序逐个`resume`这些生产者协程
* **通道为空**
* 自动`yield`当前协程,其他生产者协程`push`生产数据后,通道可读,将重新`resume`当前协程
* 多个消费者协程同时`pop`时,底层自动进行排队,底层会按照顺序逐个`resume`这些消费者协程
- 序言
- 启动停止
- 简单的开发示例
- 性能测试
- 性能测试-数据库
- 通讯协议
- 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()