YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
unique_job.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <yaclib/exe/job.hpp>
5
6#include <utility>
7
8namespace yaclib::detail {
9
10template <typename Func>
11class UniqueJob final : public Job, public SafeCall<Func> {
12 public:
13 using SafeCall<Func>::SafeCall;
14
15 private:
16 void Call() noexcept final;
17 void Drop() noexcept final;
18};
19
20template <typename Func>
23 Drop();
24}
25
26template <typename Func>
27void UniqueJob<Func>::Drop() noexcept {
28 delete this;
29}
30
31template <typename Func>
33 return new UniqueJob<decltype(std::forward<Func>(f))>{std::forward<Func>(f)};
34}
35
36} // namespace yaclib::detail
Callable that can be executed in an IExecutor.
Definition job.hpp:12
void Call() noexcept
Definition safe_call.hpp:23
Job * MakeUniqueJob(Func &&f)
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25