LinuxContainer: AsyncMutex-ify LinuxContainer #325
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change moves LinuxContainer to use the new AsyncMutex type. This allows us to keep
using our old state machine model, but lock around the entirety of operations. This also
allows us to axe quite a few states that were intermediary states only there to protect against
multiple threads calling (even if it was unlikely..) the same method at the same time (.creating,
.starting, .stopping etc.).
The rationale is: Mutex is somewhat tricky to use as you can't (for good reason) do any async
work inside the closure. This makes some of our work difficult as every single interaction
with the guest is via an rpc, which is all async. There really isn't a worry about contention,
because most container methods will only ever be invoked once (create, start, stop) so a big heavy
lock isn't much of a deterrent.