mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
Simplify
This commit is contained in:
parent
8fff3e7bb5
commit
e681b1f064
2 changed files with 14 additions and 18 deletions
|
@ -33,6 +33,7 @@ typedef enum {
|
||||||
resCorruptedPath = 103,
|
resCorruptedPath = 103,
|
||||||
resSetPhase = 104,
|
resSetPhase = 104,
|
||||||
resProgress = 105,
|
resProgress = 105,
|
||||||
|
resSetExpected = 106,
|
||||||
} ResultType;
|
} ResultType;
|
||||||
|
|
||||||
typedef uint64_t ActivityId;
|
typedef uint64_t ActivityId;
|
||||||
|
@ -72,8 +73,6 @@ public:
|
||||||
|
|
||||||
virtual void stopActivity(ActivityId act) { };
|
virtual void stopActivity(ActivityId act) { };
|
||||||
|
|
||||||
virtual void setExpected(ActivityId act, ActivityType type, uint64_t expected) { };
|
|
||||||
|
|
||||||
virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
|
virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ struct Activity
|
||||||
{ result(resProgress, done, expected, running, failed); }
|
{ result(resProgress, done, expected, running, failed); }
|
||||||
|
|
||||||
void setExpected(ActivityType type2, uint64_t expected) const
|
void setExpected(ActivityType type2, uint64_t expected) const
|
||||||
{ logger.setExpected(id, type2, expected); }
|
{ result(resSetExpected, type2, expected); }
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void result(ResultType type, const Args & ... args) const
|
void result(ResultType type, const Args & ... args) const
|
||||||
|
|
|
@ -192,21 +192,6 @@ public:
|
||||||
update(*state);
|
update(*state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExpected(ActivityId act, ActivityType type, uint64_t expected) override
|
|
||||||
{
|
|
||||||
auto state(state_.lock());
|
|
||||||
|
|
||||||
auto i = state->its.find(act);
|
|
||||||
assert(i != state->its.end());
|
|
||||||
ActInfo & actInfo = *i->second;
|
|
||||||
auto & j = actInfo.expectedByType[type];
|
|
||||||
state->activitiesByType[type].expected -= j;
|
|
||||||
j = expected;
|
|
||||||
state->activitiesByType[type].expected += j;
|
|
||||||
|
|
||||||
update(*state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void result(ActivityId act, ResultType type, const std::vector<Field> & fields) override
|
void result(ActivityId act, ResultType type, const std::vector<Field> & fields) override
|
||||||
{
|
{
|
||||||
auto state(state_.lock());
|
auto state(state_.lock());
|
||||||
|
@ -258,6 +243,18 @@ public:
|
||||||
actInfo.failed = getI(fields, 3);
|
actInfo.failed = getI(fields, 3);
|
||||||
update(*state);
|
update(*state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (type == resSetExpected) {
|
||||||
|
auto i = state->its.find(act);
|
||||||
|
assert(i != state->its.end());
|
||||||
|
ActInfo & actInfo = *i->second;
|
||||||
|
auto type = (ActivityType) getI(fields, 0);
|
||||||
|
auto & j = actInfo.expectedByType[type];
|
||||||
|
state->activitiesByType[type].expected -= j;
|
||||||
|
j = getI(fields, 1);
|
||||||
|
state->activitiesByType[type].expected += j;
|
||||||
|
update(*state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update()
|
void update()
|
||||||
|
|
Loading…
Reference in a new issue