YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
share.hpp
Go to the documentation of this file.
1#pragma once
2
7
8namespace yaclib {
9
10template <typename V, typename E>
12 auto [f, p] = MakeContract<V, E>();
13 Connect(future, std::move(p));
14 return std::move(f);
15}
16
17template <typename V, typename E>
20 Connect(future, std::move(p));
21 return std::move(f);
22}
23
24template <typename V, typename E>
26 YACLIB_ASSERT(promise.Valid());
27 auto [f, p] = MakeContract<V, E>();
28 Connect(promise, std::move(p));
29 return std::move(f);
30}
31
32template <typename V, typename E>
34 YACLIB_ASSERT(promise.Valid());
36 Connect(promise, std::move(p));
37 return std::move(f);
38}
39
40} // namespace yaclib
Provides a mechanism to access the result of async operations.
Definition future.hpp:244
Provides a mechanism to access the result of async operations.
Definition future.hpp:210
#define YACLIB_ASSERT(cond)
Definition log.hpp:85
Future< V, E > Share(const SharedFutureBase< V, E > &future)
Definition share.hpp:11
void Connect(FutureBase< V, E > &&f, Promise< V, E > &&p)
Definition connect.hpp:11
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25