-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlowControllerPolicy.h
58 lines (45 loc) · 1.8 KB
/
FlowControllerPolicy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include"RxConcurrent/CommonDefines.h"
#include"RxConcurrent/ThreadPool/TaskPolicy.h"
#include"RxConcurrent/Export.h"
namespace BaseLib { namespace Concurrent {
/** -------------------------------------------------------------------
Policy support in FlowControllerPolicy:
- bounded speeds
- flow control with congestion control
- Request last n signals to connecting observer
- Pull and push model support in observer
- Max Signal speed (Interval)
- Filter based on content
- Min speed - Deadline - expecting value in configurable intervals. Use thread-pool's monitoring of policy violation and call-back upon interval violations.
- Throughput policy (events per second)
- TODO: Priority on events? Requires weighted fair queueing
- TODO: History is max items, Lifespan is maximum lifetime in queue/history (sliding time window)
------------------------------------------------------------------- */
class DLL_STATE FlowControllerPolicy
{
public:
FlowControllerPolicy(TaskPolicy policy = TaskPolicy::RunForever());
virtual ~FlowControllerPolicy();
const TaskPolicy& Task() const;
Policy::Throughput Throughput() const;
Policy::History History() const;
Policy::MaxLimit<int> MaxQueueSize() const;
// Unused
Policy::Congestion Congestion() const;
Policy::Deadline Deadline() const;
Policy::TimeBasedFilter MinSeparation() const;
static FlowControllerPolicy Default();
private:
TaskPolicy taskPolicy_;
// ------------------------------------
// Flow control
// ------------------------------------
Policy::Throughput throughput_;
Policy::History history_;
Policy::Deadline deadline_;
Policy::MaxLimit<int> maxQueueSize_;
Policy::Congestion congestion_;
Policy::TimeBasedFilter minSeparation_;
};
}}