1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use core::sync::atomic::Ordering;
use crate::{AtomicNumber, False, Integer, IsSigned, SignedInt, True, UnsignedInt};
/// An atomic integer type.
pub trait AtomicInteger: AtomicNumber
where
Self::NonAtomicType: Integer,
{
/// Bitwise “and” with the current value.
///
/// Performs a bitwise “and” operation on the current value and the argument
/// val, and sets the new value to the result.
///
/// Returns the previous value.
///
/// [`AtomicInteger::fetch_and`] an [`Ordering`](`core::sync::atomic::Ordering`) argument
/// which describes the memory ordering of this operation. All ordering
/// modes are possible.
/// Note that using [`Acquire`](`core::sync::atomic::Ordering::Acquire`)
/// makes the store part of this operation
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`), and using
/// [`Release`](`core::sync::atomic::Ordering::Release`) makes the load part
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`).
///
/// Note: This method is only available on platforms that support atomic
/// operations on the given type.
fn fetch_and(&self, value: Self::NonAtomicType, order: Ordering) -> Self::NonAtomicType;
/// Bitwise “nand” with the current value.
///
/// Performs a bitwise “nand” operation on the current value and the
/// argument val, and sets the new value to the result.
///
/// Returns the previous value.
///
/// [`AtomicInteger::fetch_nand`] an [`Ordering`](`core::sync::atomic::Ordering`) argument
/// which describes the memory ordering of this operation. All ordering
/// modes are possible.
/// Note that using [`Acquire`](`core::sync::atomic::Ordering::Acquire`)
/// makes the store part of this operation
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`), and using
/// [`Release`](`core::sync::atomic::Ordering::Release`) makes the load part
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`).
///
/// Note: This method is only available on platforms that support atomic
/// operations on the given type.
fn fetch_nand(&self, value: Self::NonAtomicType, order: Ordering) -> Self::NonAtomicType;
/// Bitwise “or” with the current value.
///
/// Performs a bitwise “or” operation on the current value and the argument val, and sets the new value to the result.
///
/// Returns the previous value.
///
/// [`AtomicInteger::fetch_or`] an [`Ordering`](`core::sync::atomic::Ordering`) argument
/// which describes the memory ordering of this operation. All ordering
/// modes are possible.
/// Note that using [`Acquire`](`core::sync::atomic::Ordering::Acquire`)
/// makes the store part of this operation
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`), and using
/// [`Release`](`core::sync::atomic::Ordering::Release`) makes the load part
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`).
///
/// Note: This method is only available on platforms that support atomic
/// operations on the given type.
fn fetch_or(&self, value: Self::NonAtomicType, order: Ordering) -> Self::NonAtomicType;
/// Bitwise “xor” with the current value.
///
/// Performs a bitwise “xor” operation on the current value and the argument val, and sets the new value to the result.
///
/// Returns the previous value.
///
/// [`AtomicInteger::fetch_xor`] an [`Ordering`](`core::sync::atomic::Ordering`) argument
/// which describes the memory ordering of this operation. All ordering
/// modes are possible.
/// Note that using [`Acquire`](`core::sync::atomic::Ordering::Acquire`)
/// makes the store part of this operation
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`), and using
/// [`Release`](`core::sync::atomic::Ordering::Release`) makes the load part
/// [`Relaxed`](`core::sync::atomic::Ordering::Relaxed`).
///
/// Note: This method is only available on platforms that support atomic
/// operations on the given type.
fn fetch_xor(&self, value: Self::NonAtomicType, order: Ordering) -> Self::NonAtomicType;
}
/// An atomic signed integer type.
pub trait AtomicSignedInt: AtomicInteger + IsSigned<Signed = True>
where
Self::NonAtomicType: SignedInt,
{
}
/// An atomic unsigned integer type.
pub trait AtomicUnsignedInt: AtomicInteger + IsSigned<Signed = False>
where
Self::NonAtomicType: UnsignedInt,
{
}