Skip to content

Commit

Permalink
sync: document that Semaphore is fair (#3693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Apr 12, 2021
1 parent adad8fc commit 3a02d34
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tokio/src/sync/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit 3a02d34

Please sign in to comment.