writer.canWrite


如果插槽缓冲区有物理容量(缓冲的数据低于配置的字节预算),返回 true;如果预算用尽,返回 false;如果写入器已关闭或消费者已断开连接,返回 null。

🌐 Returns true if the slots buffer has physical capacity (buffered data is below the configured byte budget), false if the budget is exhausted, or null if the writer is closed or the consumer has disconnected.

这会独立于背压策略报告物理容量。使用'drop-oldest'或'drop-newest'时,当设置为false时,写入仍然会完成,分别通过驱逐缓存数据或丢弃传入数据。

🌐 This reports physical capacity independently of the backpressure policy. With 'drop-oldest' or 'drop-newest', writes still complete when this is false by evicting buffered data or discarding the incoming data, respectively.

这只是一个提示,不是保证:状态可能在检查和写入之间改变。使用 ondrain() 来等待容量,而不是轮询。

🌐 This is a hint, not a guarantee: the state can change between the check and the write. Use ondrain() to wait for capacity rather than polling.