sync: document that Semaphore is fair (#3693)

This commit is contained in:
Alice Ryhl
2021-04-12 15:46:42 +02:00
committed by GitHub
parent adad8fc3cd
commit 3a02d34d3a
+7
View File
@@ -14,6 +14,13 @@ use std::sync::Arc;
/// available, `acquire` (asynchronously) waits until an outstanding permit is
/// dropped. At this point, the freed permit is assigned to the caller.
///
/// This `Semaphore` is fair, which means that permits are given out in the order
/// they were requested. This fairness is also applied when `acquire_many` gets
/// involved, so if a call to `acquire_many` at the front of the queue requests
/// more permits than currently available, this can prevent a call to `acquire`
/// from completing, even if the semaphore has enough permits complete the call
/// to `acquire`.
///
/// To use the `Semaphore` in a poll function, you can use the [`PollSemaphore`]
/// utility.
///