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
59
60
61
62
63
64
65
66
|
#ifndef FT8_MTD_DECODE_SCHEDULER_HPP
#define FT8_MTD_DECODE_SCHEDULER_HPP
#include <QtGlobal>
class Ft8MtdDecodeScheduler
{
public:
static bool supportsBackpressure (bool multithreadedFt8,
bool standardFinalRequired)
{
return multithreadedFt8 && !standardFinalRequired;
}
enum class Stage
{
None,
EarlyOne,
EarlyTwo,
Final
};
enum class Action
{
Publish,
SkipEarly,
DeferFinal,
ReplaceFinal
};
struct Decision
{
Action action {Action::Publish};
bool enteredDegraded {false};
int skippedPeriods {0};
};
Decision request (Stage stage, qint64 period, int earlyStageCount,
bool decoderBusy, bool finalAlreadyPending);
bool published (Stage stage, qint64 period);
void completed (Stage stage, qint64 period);
void publicationFailed (Stage stage, qint64 period);
void cancel ();
bool degraded () const {return degraded_;}
int skippedPeriods () const;
qint64 nextProbePeriod () const {return nextProbePeriod_;}
private:
static constexpr int BackoffCount {4};
static constexpr int BackoffPeriods[BackoffCount] {1, 2, 4, 8};
void degrade (qint64 period, bool advance);
bool probeComplete (qint64 period) const;
void clearProbe ();
bool degraded_ {false};
int backoffIndex_ {0};
qint64 nextProbePeriod_ {0};
qint64 probePeriod_ {-1};
int probeEarlyStageCount_ {0};
int completedEarlyStages_ {0};
bool recoverOnFinalPublish_ {false};
};
#endif
|