MCPcopy Create free account
hub / github.com/Tom94/tev / enqueueCoroutine

Method enqueueCoroutine

include/tev/ThreadPool.h:77–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75 }
76
77 inline auto enqueueCoroutine(int priority) noexcept {
78 class Awaiter {
79 public:
80 Awaiter(ThreadPool* pool, int priority) : mPool{pool}, mPriority{priority} {}
81
82 bool await_ready() const noexcept { return false; }
83
84 // Suspend and enqueue coroutine continuation onto the threadpool
85 void await_suspend(std::coroutine_handle<> coroutine) noexcept { mPool->enqueueTask(coroutine, mPriority); }
86
87 void await_resume() const noexcept {}
88
89 private:
90 ThreadPool* mPool;
91 int mPriority;
92 };
93
94 return Awaiter{this, priority};
95 }
96
97 template <TaskCoroutine F> auto enqueueCoroutine(F&& fun, int priority) -> std::invoke_result_t<F> {
98 // Nesting without capture is necessary for coroutine state to be properly put on the heap (the lambda object itself goes out of

Callers 7

canvasStatisticsMethod · 0.80
enqueueMethod · 0.80
convertToFunction · 0.80
tryLoadImageFunction · 0.80
readTiffImageFunction · 0.80
loadMethod · 0.80
readDicomDirFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected