18 auto ec = stream_.Acquire();
24 size_t copy_size = chunk.size();
25 size_t stream_writable = stream_.EmptySize();
26 if (copy_size > stream_writable)
28 copy_size = stream_writable;
37 ec = stream_.Write(chunk.substr(0, copy_size));
43 retained_size_ += copy_size;
44 if (copy_size != chunk.size() || stream_.EmptySize() == 0)
67 CompiledWriteFun write_fun)
70 auto ec = write_fun(context, sink);
77 ASSERT(write_fun !=
nullptr);
104 retained_size >
static_cast<size_t>(std::numeric_limits<int>::max()))
109 return static_cast<int>(retained_size);
互斥锁类,提供线程同步机制 (Mutex class providing thread synchronization mechanisms).
ErrorCode Lock()
加锁,如果锁已被占用,则阻塞等待 (Lock the mutex, blocking if it is already locked).
void Unlock()
解锁互斥锁 (Unlock the mutex).
STDIO 编译格式会话使用的流式截断输出端 / Stream-backed truncating sink used by one STDIO compiled-format session.
ErrorCode Write(std::string_view chunk)
追加一个文本片段;必要时按会话剩余空间直接截断 / Append one text chunk and truncate directly to the remaining session capaci...
size_t RetainedSize() const
返回当前会话最终保留下来的字节数 / Return the retained byte count of the current session
CompiledSink(WritePort::Stream &stream)
构造一个绑定到指定流的编译格式输出端 / Construct one compiled-format sink bound to the given stream
static LibXR::WritePort::Stream * write_stream_
Optional externally owned write stream. 可选的外部托管写流。
static LibXR::Mutex * write_mutex_
Write port mutex. 写入端口互斥锁。
static int WriteCompiledToStream(WritePort::Stream &stream, void *context, CompiledWriteFun write_fun)
在指定 Stream 上执行一次完整的 STDIO 编译格式写入与收尾 / Run one complete STDIO compiled-format write and finalize pass ...
static int FinishWriteSession(WritePort::Stream &stream, size_t retained_size, ErrorCode format_result)
提交当前编译格式会话的写入流并释放共享会话 / Commit the current compiled-format session stream and release the shared sess...
static int WriteCompiledSession(void *context, CompiledWriteFun write_fun)
执行一次完整的 STDIO 编译格式流会话选择、写入与收尾 / Run one complete STDIO compiled-format stream session: stream selecti...
static WritePort * write_
Write port instance. 写入端口。
static bool BeginWriteSession()
获取一个共享的 STDIO 写入会话 / Acquire one shared STDIO write session
ErrorCode Commit()
手动提交已写入的数据到队列,并释放当前锁。
@ OK
操作成功 | Operation successful