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 E>
13using Contract = std::pair<Future<V, E>, Promise<V, E>>;
14
15template <typename V, typename E>
16using ContractOn = std::pair<FutureOn<V, E>, Promise<V, E>>;
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 E = StopError>
31
32template <typename V = void, typename E = StopError>
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:232
Provides a mechanism to access the result of async operations.
Definition future.hpp:199
A intrusive pointer to objects with an embedded reference count.
ContractOn< V, E > MakeContractOn(IExecutor &e)
Definition contract.hpp:33
std::pair< FutureOn< V, E >, Promise< V, E > > ContractOn
Definition contract.hpp:16
std::pair< Future< V, E >, Promise< V, E > > Contract
Describes channel with future and promise.
Definition contract.hpp:13
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25