1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-11-02 08:34:44 +00:00

refactor: remove transport knowledge from Laminar class

Improve the boundary between RpcImpl and LaminarInterface such
that the Laminar class doesn't require any types from kj/async.h.
The necessary logic moved from Laminar to RpcImpl and the notification
now happens by abstract virtual callback instead of kj::Promise.
Also remove the fairly useless 'wait' RPC call and drop the wrappers
around kj::PromiseFulfillerPair
This commit is contained in:
Oliver Giles
2017-08-10 08:25:20 +03:00
parent ab99af7ca7
commit eda906b805
6 changed files with 56 additions and 86 deletions

View File

@@ -108,6 +108,14 @@ void Laminar::deregisterClient(LaminarClient* client) {
clients.erase(client);
}
void Laminar::registerWaiter(LaminarWaiter *waiter) {
waiters.insert(waiter);
}
void Laminar::deregisterWaiter(LaminarWaiter *waiter) {
waiters.erase(waiter);
}
bool Laminar::setParam(std::string job, int buildNum, std::string param, std::string value) {
if(Run* run = activeRun(job, buildNum)) {
run->params[param] = value;
@@ -471,17 +479,6 @@ std::shared_ptr<Run> Laminar::queueJob(std::string name, ParamMap params) {
return run;
}
kj::Promise<RunState> Laminar::waitForRun(std::string name, int buildNum) {
if(const Run* run = activeRun(name, buildNum))
return waitForRun(run);
return RunState::UNKNOWN;
}
kj::Promise<RunState> Laminar::waitForRun(const Run* run) {
waiters[run].emplace_back(Waiter{});
return waiters[run].back().takePromise();
}
bool Laminar::stepRun(std::shared_ptr<Run> run) {
bool complete = run->step();
if(!complete) {
@@ -723,10 +720,10 @@ void Laminar::runFinished(Run * r) {
c->sendMessage(msg);
}
// wake the waiters
for(Waiter& waiter : waiters[r])
waiter.release(r->result);
waiters.erase(r);
// notify the waiters
for(LaminarWaiter* w : waiters) {
w->complete(r);
}
// remove the rundir
fs::remove_all(r->runDir);