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
>
4
#include <
yaclib/util/detail/safe_call.hpp
>
5
6
#include <utility>
7
8
namespace
yaclib::detail
{
9
10
template
<
typename
Func>
11
class
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
20
template
<
typename
Func>
21
void
UniqueJob<Func>::Call
()
noexcept
{
22
SafeCall<Func>::Call
();
23
Drop();
24
}
25
26
template
<
typename
Func>
27
void
UniqueJob<Func>::Drop()
noexcept
{
28
delete
this
;
29
}
30
31
template
<
typename
Func>
32
Job
*
MakeUniqueJob
(
Func
&&
f
) {
33
return
new
UniqueJob<decltype(std::forward<Func>
(
f
))>{std::forward<Func>(
f
)};
34
}
35
36
}
// namespace yaclib::detail
yaclib::Job
Callable that can be executed in an IExecutor.
Definition
job.hpp:12
yaclib::detail::SafeCall
Definition
safe_call.hpp:11
yaclib::detail::SafeCall::Call
void Call() noexcept
Definition
safe_call.hpp:23
yaclib::detail::UniqueJob
Definition
unique_job.hpp:11
job.hpp
yaclib::detail
Definition
base_core.hpp:18
yaclib::detail::MakeUniqueJob
Job * MakeUniqueJob(Func &&f)
Definition
unique_job.hpp:32
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
safe_call.hpp
include
yaclib
exe
detail
unique_job.hpp
Generated by
1.9.8