mFrame
載入中...
搜尋中...
無符合項目
PFuture.h
1
7#ifndef MFRAME_1C1490D6_E331_4C8B_A1CC_49D7A5549037
8#define MFRAME_1C1490D6_E331_4C8B_A1CC_49D7A5549037
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15
16//----------------------------------------------------------------------------------------
17#include "./../lang/Object.h"
18#include "./../sys/Thread.h"
19#include "./../util/Future.h"
20
21/* ***************************************************************************************
22 * Namespace
23 */
24namespace ufm::util {
25 class PFuture;
26} // namespace ufm::util
27
28namespace ufm::io {
29 struct OutputStream;
30} // namespace ufm::io
31
32namespace ufm::lang {
33 struct Readable;
34} // namespace ufm::lang
35
36/* ***************************************************************************************
37 * Class/Interface/Struct/Enum
38 */
39
77 /* *************************************************************************************
78 * Variable
79 */
80 private:
81 int vResult;
83 ufm::sys::Thread* vThread;
84
85 /* *************************************************************************************
86 * Abstract Method
87 */
88
89 /* *************************************************************************************
90 * Construct Method
91 */
92 public:
98 PFuture(void);
99
105 virtual ~PFuture(void) override;
106
107 /* *************************************************************************************
108 * Operator Method
109 */
110 public:
119 template <typename E>
120 inline operator const Future<E>&(void) const {
121 const Future<>* src = this;
122 return *reinterpret_cast<const Future<E>*>(src);
123 }
124
133 template <typename E>
134 inline operator Future<E>&(void) {
135 Future<>* src = this;
136 return *reinterpret_cast<Future<E>*>(src);
137 }
138
139 /* *************************************************************************************
140 * Override Method - ufm::util::Future<>
141 */
142 public:
154 virtual bool get(int& result, int timeout) override;
155
165 virtual bool setWait(void) override;
166
177 virtual bool waitDone(int timeout) override;
178
185 virtual void clear(void) override;
186
196 virtual ufm::util::FutureStatus getStatus(void) override;
197
198 /* *************************************************************************************
199 * Override Method - ufm::util::Future<>
200 */
201 public:
213 virtual void completed(int& result, void* attachment) override;
214
225 virtual void failed(void* attachment) override;
226
227 /* *************************************************************************************
228 * Public Method
229 */
230 public:
250 bool isBusy(void) const;
251
276 ufm::lang::Readable& readable,
277 int timeoutMs = 5000);
278
279 /* *************************************************************************************
280 * Protected Method
281 */
282 protected:
288 void setCompleted(void);
289
295 void setFailed(void);
296
297 /* *************************************************************************************
298 * Private Method
299 */
300
301 /* *************************************************************************************
302 * Static Variable
303 */
304
305 /* *************************************************************************************
306 * Static Method
307 */
308};
309
310/* ***************************************************************************************
311 * End of file
312 */
313
314#endif /* MFRAME_1C1490D6_E331_4C8B_A1CC_49D7A5549037 */
物件基底類別
Definition Object.h:63
執行緒類別
Definition Thread.h:49
[Class] 可處理的 Future 實作類別
Definition PFuture.h:76
virtual bool waitDone(int timeout) override
等待異步操作完成
virtual void completed(int &result, void *attachment) override
處理異步操作完成的回調
PFuture(void)
構造一個新的 PFuture 物件
virtual ~PFuture(void) override
銷毀 PFuture 物件
void setFailed(void)
將 Future 標記為失敗狀態
virtual ufm::util::FutureStatus getStatus(void) override
獲取當前 Future 的狀態
virtual void failed(void *attachment) override
處理異步操作失敗的回調
virtual bool setWait(void) override
將 Future 設置為等待狀態
int syncWrite(ufm::io::OutputStream &outputStream, ufm::lang::Readable &readable, int timeoutMs=5000)
執行帶超時的同步寫入操作
virtual void clear(void) override
清除 Future 的狀態
bool isBusy(void) const
檢查 Future 是否處於忙碌狀態
void setCompleted(void)
將 Future 標記為已完成狀態
virtual bool get(int &result, int timeout) override
獲取異步操作的結果
Definition Buffer.h:24
Definition Appendable.h:23
Definition Iterable.h:28
FutureStatus
異步操作狀態列舉,定義 Future 物件的所有可能狀態。
Definition FutureStatus.h:239
[Interface] 提供輸出串流的基本操作方法
Definition OutputStream.h:37
[Interface] 定義資料讀取介面
Definition Readable.h:46
非同步操作結果介面,提供異步任務的監控和結果獲取功能。
Definition Future.h:310