YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
combinator_strategy.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace yaclib {
7
8// Every combinator strategy shall be parametrized with the following template arguments
9// template <FailPolicy F, typename OutputValue, typename OutputError, typename InputCore>
10// struct ExampleStrategy;
11//
12// It must also have
13// using PromiseType = Promise<OutputValue, OutputError>
14// for the combinator to know the type of Promise to pass to the strategy
15
16// Every combinator stategy must have the following two static variables defined:
17// - ConsumePolicy kConsumePolicy = None | Unordered | Static | Dynamic;
18// - CorePolicy kCorePolicy = Owned | Managed;
19
20// This defines what kind of the Consume method will be called
21// All kinds of Consume will have the `target` parameter, which will be a Core or a Result,
22// depending on CorePolicy. Cores should usually be taken by lvalue reference, while
23// Results should be taken by universal refernce
24enum class ConsumePolicy {
25 None, // no Strategy::Consume() method will be called
26 Unordered, // Strategy::Consume(target) will be called
27 Static, // Strategy::Consume<Index>(target) will be called
28 Dynamic, // Strategy::Consume(index, target) will be called
29};
30
31// Owned means the strategy owns the cores and manages them by itself
32// while Managed means that the Results from the Cores will be passed
33// to the strategy in Strategy::Consume()
34// but the Cores themselves will be managed on the outside
35enum class CorePolicy {
36 // For every Core, Strategy::Register(index, core) will be called before setting the callbacks
37 // Also, Strategy::Consume, if present, will receive the Core
38 Owned,
39 // Strategy::Consume, if present, will receive the Result
40 Managed,
41};
42
43// The related code is located in async/when/when.hpp
44
45} // namespace yaclib