MCPcopy Create free account
hub / github.com/3rdparty/libprocess / AsyncExecutorProcess

Class AsyncExecutorProcess

include/process/async.hpp:68–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67// TODO(vinod): Merge this into ExecutorProcess.
68class AsyncExecutorProcess : public Process<AsyncExecutorProcess>
69{
70private:
71 friend class AsyncExecutor;
72
73 AsyncExecutorProcess() : ProcessBase(ID::generate("__async_executor__")) {}
74 ~AsyncExecutorProcess() override {}
75
76 // Not copyable, not assignable.
77 AsyncExecutorProcess(const AsyncExecutorProcess&);
78 AsyncExecutorProcess& operator=(const AsyncExecutorProcess&);
79
80 template <
81 typename F,
82 typename std::enable_if<
83 !std::is_void<typename result_of<F()>::type>::value, int>::type = 0>
84 typename result_of<F()>::type execute(const F& f)
85 {
86 terminate(self()); // Terminate process after function returns.
87 return f();
88 }
89
90 template <
91 typename F,
92 typename std::enable_if<
93 std::is_void<typename result_of<F()>::type>::value, int>::type = 0>
94 Nothing execute(const F& f)
95 {
96 terminate(self()); // Terminate process after function returns.
97 f();
98 return Nothing();
99 }
100
101#define TEMPLATE(Z, N, DATA) \
102 template < \
103 typename F, \
104 ENUM_PARAMS(N, typename A), \
105 typename std::enable_if< \
106 !std::is_void< \
107 typename result_of<F(ENUM_PARAMS(N, A))>::type>::value, \
108 int>::type = 0> \
109 typename result_of<F(ENUM_PARAMS(N, A))>::type execute( \
110 const F& f, ENUM_BINARY_PARAMS(N, A, a)) \
111 { \
112 terminate(self()); /* Terminate process after function returns. */ \
113 return f(ENUM_PARAMS(N, a)); \
114 } \
115 \
116 template < \
117 typename F, \

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected