YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
contract.hpp
Go to the documentation of this file.
1#pragma once
2
6
7namespace yaclib {
8
9/**
10 * Describes channel with future and promise
11 */
12template <typename V, typename T>
13using Contract = std::pair<Future<V, T>, Promise<V, T>>;
14
15template <typename V, typename T>
16using ContractOn = std::pair<FutureOn<V, T>, Promise<V, T>>;
17// TODO(kononovk) Make Contract a struct, not std::pair or std::tuple
18
19/**
20 * Creates related future and promise
21 *
22 * \return a \see Contract object with new future and promise
23 */
24template <typename V = void, typename T = DefaultTrait>
31
32template <typename V = void, typename T = DefaultTrait>
35 e.IncRef();
36 core->_executor.Reset(NoRefTag{}, &e);
39 return {std::move(future), std::move(promise)};
40}
41
42} // namespace yaclib
Provides a mechanism to access the result of async operations.
Definition future.hpp:247
Provides a mechanism to access the result of async operations.
Definition future.hpp:213
A intrusive pointer to objects with an embedded reference count.
Contract< V, T > MakeContract()
Creates related future and promise.
Definition contract.hpp:25
ContractOn< V, T > MakeContractOn(IExecutor &e)
Definition contract.hpp:33
std::pair< FutureOn< V, T >, Promise< V, T > > ContractOn
Definition contract.hpp:16
std::pair< Future< V, T >, Promise< V, T > > Contract
Describes channel with future and promise.
Definition contract.hpp:13