From de9fa48c5a4af7af4d63f25161018424480c4ab8 Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Wed, 26 Aug 2020 10:48:19 -0600 Subject: [PATCH] Added a note about why all the resources are behind a single Mutex rather than multiple Mutexes per resource --- src/renderer_server/access_control.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/renderer_server/access_control.rs b/src/renderer_server/access_control.rs index 51cb3eef..8d6d367d 100644 --- a/src/renderer_server/access_control.rs +++ b/src/renderer_server/access_control.rs @@ -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>; /// Manages access to the app state, enforcing the rules around sequential consistency and