Skip to content

Commit

Permalink
SharedData: Update locks to mention possible deadlocks (paritytech#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 and grishasobol committed Mar 28, 2022
1 parent 8872617 commit 4d2abe2
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 4d2abe2

Please sign in to comment.