class GRPC::Transport::LiveSendBuffer

Overview

LiveSendBuffer is an on-demand queue for full-duplex bidi streaming. DATA_READ_CB_LIVE returns NGHTTP2_ERR_DEFERRED when the queue is empty, and the caller must call session_resume_data after pushing new data.

When capacity > 0 the buffer is bounded: push blocks the calling fiber until a slot is available, providing backpressure to the sender. capacity == 0 (default) means unbounded.

Lock ordering: callers must NOT hold @lsb_mutex while acquiring the connection @mutex. read_into is called from inside the connection @mutex, so it acquires @lsb_mutex as an inner lock — which is safe because push/close always release @lsb_mutex before the caller acquires the connection @mutex (via send_resume_proc).

Defined in:

grpc/transport/http2_client_connection.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(capacity : Int32 = 0) #

[View source]

Instance Method Detail

def close : Nil #

[View source]
def closed? : Bool #

[View source]
def push(bytes : Bytes) : Nil #

[View source]
def read_into(buf : Pointer(UInt8), length : LibC::SizeT, data_flags : Pointer(UInt32)) : LibC::SSizeT #

read_into fills buf with up to length bytes from the queue. Returns the number of bytes written, sets DATA_FLAG_EOF when done, or returns NGHTTP2_ERR_DEFERRED when no data is available yet. Called from DATA_READ_CB_LIVE while the connection @mutex is held.


[View source]
def take_resume_request : Bool #

[View source]