mFrame
載入中...
搜尋中...
無符合項目
OutputStream.h
1
7#ifndef MFRAME_BF429992_9D4C_4C5C_B6B7_69C9B0F86EA1
8#define MFRAME_BF429992_9D4C_4C5C_B6B7_69C9B0F86EA1
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15
16//----------------------------------------------------------------------------------------
17#include "./../io/CompletionHandler.h"
18#include "./../lang/Readable.h"
19#include "./../util/Future.h"
20
21/* ***************************************************************************************
22 * Namespace
23 */
24namespace ufm::io {
25 struct OutputStream;
26} // namespace ufm::io
27
28/* ***************************************************************************************
29 * Class/Interface/Struct/Enum
30 */
31
45 virtual bool abortWrite(void) abstract;
46
54 virtual bool writeBusy(void) abstract;
55
66 virtual bool write(ufm::lang::Readable& readable,
67 void* attachment,
68 ufm::io::CompletionHandler<int>* handler) abstract;
69
79 inline bool write(ufm::lang::Readable& readable, ufm::util::Future<int>& future) {
80 if (future.isBusy()) return false;
81
82 future.setWait();
83 if (this->write(readable, nullptr, &future)) return true;
84
85 future.failed(nullptr);
86 return false;
87 }
88};
89
90/* ***************************************************************************************
91 * End of file
92 */
93
94#endif /* MFRAME_BF429992_9D4C_4C5C_B6B7_69C9B0F86EA1 */
Definition Buffer.h:24
[Interface] 非同步操作完成事件處理器模板介面
Definition CompletionHandler.h:42
virtual void failed(void *attachment) override
當非同步操作失敗時呼叫
[Interface] 提供輸出串流的基本操作方法
Definition OutputStream.h:37
virtual bool abortWrite(void) override
取消當前的輸出串流寫入
bool write(ufm::lang::Readable &readable, ufm::util::Future< int > &future)
寫入資料到輸出串流,並使用Future來處理結果
Definition OutputStream.h:79
virtual bool write(ufm::lang::Readable &readable, void *attachment, ufm::io::CompletionHandler< int > *handler) override
寫入資料到輸出串流
virtual bool writeBusy(void) override
取得輸出串流是否為寫入忙碌
[Interface] 定義資料讀取介面
Definition Readable.h:46
[Interface] 非同步操作結果介面
Definition Future.h:43
virtual bool setWait(void) override
設置為等待狀態
bool isBusy(void)
檢查操作是否處於忙碌(等待)狀態
Definition Future.h:157