hydra-queue-runner: Detect changes to the scheduling shares

This commit is contained in:
Eelco Dolstra
2015-08-12 13:17:56 +02:00
parent 2e3899ed27
commit d4759c1da2
4 changed files with 52 additions and 9 deletions

View File

@@ -67,14 +67,12 @@ public:
typedef std::shared_ptr<Jobset> ptr;
typedef std::weak_ptr<Jobset> wptr;
Jobset(unsigned int shares) : shares(shares) { }
static const time_t schedulingWindow = 24 * 60 * 60;
private:
std::atomic<time_t> seconds{0};
std::atomic<unsigned int> shares;
std::atomic<unsigned int> shares{1};
/* The start time and duration of the most recent build steps. */
Sync<std::map<time_t, time_t>> steps;
@@ -86,6 +84,12 @@ public:
return (double) seconds / shares;
}
void setShares(int shares_)
{
assert(shares_ > 0);
shares = shares_;
}
time_t getSeconds() { return seconds; }
void addStep(time_t startTime, time_t duration);
@@ -354,6 +358,8 @@ private:
Jobset::ptr createJobset(pqxx::work & txn,
const std::string & projectName, const std::string & jobsetName);
void processJobsetSharesChange(Connection & conn);
void makeRunnable(Step::ptr step);
/* The thread that selects and starts runnable builds. */