YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
shared_func.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
yaclib/util/detail/safe_call.hpp
>
4
#include <
yaclib/util/func.hpp
>
5
#include <
yaclib/util/helper.hpp
>
6
#include <
yaclib/util/intrusive_ptr.hpp
>
7
#include <
yaclib/util/ref.hpp
>
8
9
#include <type_traits>
10
#include <utility>
11
12
namespace
yaclib
{
13
namespace
detail {
14
15
template
<
typename
Func>
16
class
SharedFunc
:
public
IFunc
,
public
SafeCall
<Func> {
17
public
:
18
using
SafeCall
<
Func
>::SafeCall;
19
20
private
:
21
void
Call()
noexcept
final
{
22
SafeCall<Func>::Call
();
23
}
24
};
25
26
}
// namespace detail
27
28
using
IFuncPtr
=
IntrusivePtr<IFunc>
;
29
30
/**
31
* Create shared \ref IFunc object from any Callable func
32
*
33
* \param f Callable object
34
*/
35
template
<
typename
Func>
36
IFuncPtr
MakeFunc
(
Func
&&
f
) {
37
return
MakeShared<detail::SharedFunc<Func>
>(1, std::forward<Func>(
f
));
38
}
39
40
}
// namespace yaclib
yaclib::IFunc
Callable interface.
Definition
func.hpp:13
yaclib::IntrusivePtr
A intrusive pointer to objects with an embedded reference count.
Definition
intrusive_ptr.hpp:17
yaclib::detail::SafeCall
Definition
safe_call.hpp:11
yaclib::detail::SafeCall::Call
void Call() noexcept
Definition
safe_call.hpp:23
yaclib::detail::SharedFunc
Definition
shared_func.hpp:16
func.hpp
helper.hpp
intrusive_ptr.hpp
yaclib
Definition
base_core.hpp:18
yaclib::MakeFunc
IFuncPtr MakeFunc(Func &&f)
Create shared IFunc object from any Callable func.
Definition
shared_func.hpp:36
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
ref.hpp
safe_call.hpp
include
yaclib
util
detail
shared_func.hpp
Generated by
1.9.8