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
3
#include <
yaclib/async/promise.hpp
>
4
#include <
yaclib/util/fail_policy.hpp
>
5
6
namespace
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
24
enum 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
35
enum 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
fail_policy.hpp
yaclib
Definition
base_core.hpp:15
yaclib::ConsumePolicy
ConsumePolicy
Definition
combinator_strategy.hpp:24
yaclib::ConsumePolicy::Unordered
@ Unordered
yaclib::ConsumePolicy::None
@ None
yaclib::ConsumePolicy::Static
@ Static
yaclib::ConsumePolicy::Dynamic
@ Dynamic
yaclib::CorePolicy
CorePolicy
Definition
combinator_strategy.hpp:35
yaclib::CorePolicy::Owned
@ Owned
yaclib::CorePolicy::Managed
@ Managed
promise.hpp
include
yaclib
util
combinator_strategy.hpp
Generated by
1.9.8