mFrame
載入中...
搜尋中...
無符合項目
Future.h
1
8#ifndef MFRAME_858D7963_BBA9_4496_8D4B_B2D77E1330CC
9#define MFRAME_858D7963_BBA9_4496_8D4B_B2D77E1330CC
10
11/* ***************************************************************************************
12 * Include
13 */
14
15//----------------------------------------------------------------------------------------
16
17//----------------------------------------------------------------------------------------
18#include "./../io/CompletionHandler.h"
19#include "./../util/FutureStatus.h"
20
21/* ***************************************************************************************
22 * Namespace
23 */
24namespace mframe::util {
25 template <typename R>
26 struct Future;
27} // namespace mframe::util
28
29/* ***************************************************************************************
30 * Class/struct/Struct/Enum
31 */
32template <typename R = int>
34 /* *************************************************************************************
35 * Method
36 */
37 virtual bool get(R& result, int timeout) abstract;
38
39 virtual bool setWait(void) abstract;
40
41 virtual bool waitDone(int timeout) abstract;
42
43 virtual void clear(void) abstract;
44
45 virtual FutureStatus getStatus(void) abstract;
46 /* *************************************************************************************
47 * Method default
48 */
49 inline bool waitDone(void) {
50 return this->waitDone(0);
51 }
52
53 inline bool get(R& result) {
54 return this->get(result, 0);
55 }
56
57 inline bool isDone(void) {
58 mframe::util::FutureStatus status = this->getStatus();
59 return ((status == mframe::util::FutureStatus::DONE_COMPLETED) ||
60 (status == mframe::util::FutureStatus::DONE_FAILED));
61 }
62
63 inline bool isCompleted(void) {
64 return (this->getStatus() == mframe::util::FutureStatus::DONE_COMPLETED);
65 }
66
67 inline bool isFailed(void) {
68 return (this->getStatus() == mframe::util::FutureStatus::DONE_FAILED);
69 }
70
71 inline bool isIdle(void) {
72 return (this->getStatus() == mframe::util::FutureStatus::IDLE);
73 }
74
75 inline bool isBusy(void) {
76 return (this->getStatus() == mframe::util::FutureStatus::WAIT);
77 }
78};
79
80/* ***************************************************************************************
81 * End of file
82 */
83
84#endif /* MFRAME_858D7963_BBA9_4496_8D4B_B2D77E1330CC */
Definition Array.h:22
Definition CompletionHandler.h:32
Definition Future.h:33