Skip to content

Commit

Permalink
Added a note about why all the resources are behind a single Mutex ra…
Browse files Browse the repository at this point in the history
…ther than multiple Mutexes per resource
  • Loading branch information
sunjay committed Aug 26, 2020
1 parent a2c5393 commit de9fa48
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/renderer_server/access_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ use parking_lot::Mutex;

use super::app::{App, TurtleId};

// Note: It is important that all of the resources be protected together by a Mutex rather than
// individually on a per-resource basis. This is how we guarantee that if a request needs multiple
// resources, it is able to reserve them all at once. Without that, two requests could race to
// reserve the same resources and end up deadlocked because the requests were queued in the wrong
// order.
type SharedResources = Arc<Mutex<Resources>>;

/// Manages access to the app state, enforcing the rules around sequential consistency and
Expand Down

0 comments on commit de9fa48

Please sign in to comment.