Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
SharedData: Update locks to mention possible deadlocks (#11034)
Browse files Browse the repository at this point in the history
* SharedData: Update locks to mention possible deadlocks

* Update `Cargo.lock`
  • Loading branch information
bkchr authored Mar 15, 2022
1 parent 80a90e7 commit 8b26ac9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/consensus/common/src/shared_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ struct SharedDataInner<T> {
/// // As we don't know the order of the threads, we need to check for both combinations
/// assert!(*data == "hello world321" || *data == "hello world312");
/// ```
///
/// # Deadlock
///
/// Be aware that this data structure doesn't give you any guarantees that you can not create a
/// deadlock. If you use [`release_mutex`](SharedDataLocked::release_mutex) followed by a call
/// to [`shared_data`](Self::shared_data) in the same thread will make your program dead lock.
/// The same applies when you are using a single threaded executor.
pub struct SharedData<T> {
inner: Arc<Mutex<SharedDataInner<T>>>,
cond_var: Arc<Condvar>,
Expand Down

0 comments on commit 8b26ac9

Please sign in to comment.