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
7#include <yaclib/util/ref.hpp>
8
9#include <type_traits>
10#include <utility>
11
12namespace yaclib {
13namespace detail {
14
15template <typename Func>
16class SharedFunc : public IFunc, public SafeCall<Func> {
17 public:
18 using SafeCall<Func>::SafeCall;
19
20 private:
21 void Call() noexcept final {
23 }
24};
25
26} // namespace detail
27
29
30/**
31 * Create shared \ref IFunc object from any Callable func
32 *
33 * \param f Callable object
34 */
35template <typename Func>
37 return MakeShared<detail::SharedFunc<Func>>(1, std::forward<Func>(f));
38}
39
40} // namespace yaclib
Callable interface.
Definition func.hpp:13
A intrusive pointer to objects with an embedded reference count.
void Call() noexcept
Definition safe_call.hpp:23
IFuncPtr MakeFunc(Func &&f)
Create shared IFunc object from any Callable func.
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25