instance_copy_on_write/
lib.rs1#[derive(Copy, Clone, Debug, PartialEq, Eq)]
16 pub enum ICoWLockTypes
17 {
18 Atomic,
20
21 RwLock,
23 }
24
25impl fmt::Display for ICoWLockTypes
26{
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
28 {
29 match self
30 {
31 Self::Atomic =>
32 write!(f, "atomic"),
33 Self::RwLock =>
34 write!(f, "rwlock"),
35 }
36 }
37}
38
39#[derive(Copy, Clone, Debug, PartialEq, Eq)]
41pub enum ICoWError
42{
43 ExclusiveLockPending,
46
47 WouldBlock,
49
50 AlreadyUpdated,
52
53 RaceCondition
55}
56
57impl fmt::Display for ICoWError
58{
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
60 {
61 match self
62 {
63 Self::ExclusiveLockPending =>
64 write!(f, "already exlcusivly locked"),
65 Self::WouldBlock =>
66 write!(f, "cannot perform try operation due to blocking"),
67 Self::AlreadyUpdated =>
68 write!(f, "the value has been updated before the current thread"),
69 Self::RaceCondition =>
70 write!(f, "a race condition detected"),
71 }
72 }
73}
74
75extern crate crossbeam_utils;
76extern crate crossbeam_deque;
77
78#[cfg(all(target_has_atomic = "ptr", feature = "prefer_atomic"))]
80pub mod cow;
81
82#[cfg(any(not(target_has_atomic = "ptr"), not(feature = "prefer_atomic")))]
84pub mod cow_mutex;
85
86use std::fmt;
87
88#[cfg(all(target_has_atomic = "ptr", feature = "prefer_atomic"))]
89pub use cow::{ICoW, ICoWRead, ICoWCopy, ICoWLock};
90
91#[cfg(any(not(target_has_atomic = "ptr"), not(feature = "prefer_atomic")))]
92pub use cow_mutex::{ICoW, ICoWRead, ICoWCopy, ICoWLock};