Closed Profpatsch closed 3 years ago
@symphorien, can you try this out, I think this supersedes https://github.com/nix-community/lorri/pull/3 in a more principled way, while also simplifying the whole thing considerably.
~I can still reproduce https://github.com/target/lorri/issues/464 on top of this PR.~
Ah no sorry, I had my timing off, it works.
Okay, added the change log, will merge and then we can release a new version upstream.
It looks like this builds the project on every ping.
It looks like this builds the project on every ping.
I didn't encounter that behavior.
See https://github.com/nix-community/lorri/issues/11 for reproducer.
fix(build_loop): always schedule at most one other build 80e8eb1
This switches the build loop from blockingly running a build for every event that ever appeared, to always at most running one additional build as soon as the current one finishes.
Whenver we start a new build, we take the current state of the environment to run nix, which means that all events that happen while a build is running (e.g. pings, filesystem events &c.) should be collapsed into one (1) extra build to be scheduled right after the current build finishes.
So there is now a stateful
current_build
variable, which contains oneBuildState
that is mutably updated fromNotRunning
toRunning
and if it’s already running toRunningAndScheduled
. Then the “build finished” event becomes just another handler in our giantselect!
, meaning that as soon as a build finishes we can either go back toNotRunning
or go toRunning
if there had been another build scheduled.For now this means inlining
once_with_send
into the build loop, further refactors to follow to make the logic easier to understand.Checklist
release.nix
(seerelease.nix
for instructions)