From 8463af92afb398aa94600eaac84eafe3ee83b737 Mon Sep 17 00:00:00 2001 From: zixuan zhao Date: Thu, 11 Jan 2024 05:15:57 -0500 Subject: [PATCH] sync: document FIFO behavior of `tokio::sync::Mutex` (#6279) Signed-off-by: azuredream --- tokio/src/sync/mutex.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokio/src/sync/mutex.rs b/tokio/src/sync/mutex.rs index 52ba2d34f..30f0bdece 100644 --- a/tokio/src/sync/mutex.rs +++ b/tokio/src/sync/mutex.rs @@ -17,6 +17,10 @@ use std::{fmt, mem, ptr}; /// differences: [`lock`] is an async method so does not block, and the lock /// guard is designed to be held across `.await` points. /// +/// Tokio's Mutex operates on a guaranteed FIFO basis. +/// This means that the order in which tasks call the [`lock`] method is +/// the exact order in which they will acquire the lock. +/// /// # Which kind of mutex should you use? /// /// Contrary to popular belief, it is ok and often preferred to use the ordinary