Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
22 lines (18 loc) · 621 Bytes

3.2.4 - Coroutine/Channel->stats.md

File metadata and controls

22 lines (18 loc) · 621 Bytes

Coroutine\Channel->stats

获取通道的状态。函数原型:

function Coroutine\Channel->stats() : array;

返回值

返回一个数组,缓冲通道将包括4项信息,无缓冲通道返回2项信息

  • consumer_num 消费者数量,表示当前通道为空,有N个协程正在等待其他协程调用push方法生产数据
  • producer_num 生产者数量,表示当前通道已满,有N个协程正在等待其他协程调用pop方法消费数据
  • queue_num 通道中的元素数量
array(
  "consumer_num" => 0,
  "producer_num" => 1,
  "queue_num" => 10
);