Coverage Report

Created: 2024-10-16 07:58

/rust/registry/src/index.crates.io-6f17d22bba15001f/parking_lot-0.12.3/src/raw_fair_mutex.rs
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2016 Amanieu d'Antras
2
//
3
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5
// http://opensource.org/licenses/MIT>, at your option. This file may not be
6
// copied, modified, or distributed except according to those terms.
7
8
use crate::raw_mutex::RawMutex;
9
use lock_api::RawMutexFair;
10
11
/// Raw fair mutex type backed by the parking lot.
12
pub struct RawFairMutex(RawMutex);
13
14
unsafe impl lock_api::RawMutex for RawFairMutex {
15
    const INIT: Self = RawFairMutex(<RawMutex as lock_api::RawMutex>::INIT);
16
17
    type GuardMarker = <RawMutex as lock_api::RawMutex>::GuardMarker;
18
19
    #[inline]
20
0
    fn lock(&self) {
21
0
        self.0.lock()
22
0
    }
23
24
    #[inline]
25
0
    fn try_lock(&self) -> bool {
26
0
        self.0.try_lock()
27
0
    }
28
29
    #[inline]
30
0
    unsafe fn unlock(&self) {
31
0
        self.unlock_fair()
32
0
    }
33
34
    #[inline]
35
0
    fn is_locked(&self) -> bool {
36
0
        self.0.is_locked()
37
0
    }
38
}
39
40
unsafe impl lock_api::RawMutexFair for RawFairMutex {
41
    #[inline]
42
0
    unsafe fn unlock_fair(&self) {
43
0
        self.0.unlock_fair()
44
0
    }
45
46
    #[inline]
47
0
    unsafe fn bump(&self) {
48
0
        self.0.bump()
49
0
    }
50
}
51
52
unsafe impl lock_api::RawMutexTimed for RawFairMutex {
53
    type Duration = <RawMutex as lock_api::RawMutexTimed>::Duration;
54
    type Instant = <RawMutex as lock_api::RawMutexTimed>::Instant;
55
56
    #[inline]
57
0
    fn try_lock_until(&self, timeout: Self::Instant) -> bool {
58
0
        self.0.try_lock_until(timeout)
59
0
    }
60
61
    #[inline]
62
0
    fn try_lock_for(&self, timeout: Self::Duration) -> bool {
63
0
        self.0.try_lock_for(timeout)
64
0
    }
65
}