This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor read and write locks to minimize lock duration
Addresses issue #249 There are some lock acquisition behavior that exists in `service.rs` which leads to non-obvious lock retention lifetimes. The syntactic sugar pattern matching that rust allows ends up hiding the lifetime acquisition of references to a locked global state. These locks end up getting held across async boundaries unnecessarily which will only lead to lock contention when it is not needed. Additionally, in at least one case, the lock acquisition lifetimes will result in a deadlock as a `write_arc` is being attempted when the write lock is already being held in a parent closure: `service.rs:630`. In order to improve the lock contention and to avoid the deadlock potential the lock guards have been made explicit and placed behind a closure ensuring that it will be cleaned up as soon as the information needed from it is accessed. Any information outside of the lock is cloned in order to ensure no further lock is required. The data that has been cloned / copied out of the lock fields was already being cloned / copied regardless. The end result should be an improved representation of the lock guard's lifetimes, and clarity of the closures that hold a lock guard.
- Loading branch information
Showing
1 changed file
with
102 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters