diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-05 17:53:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 17:53:09 -0400 |
commit | 80df9aec1db449e6cc0f4513103aa442b8d43de3 (patch) | |
tree | e5a36781b8b75253b4896a2cdfd46116fde5af71 /cli/util/sync | |
parent | d4d3a3c54f5e26dec0cc79e273dc488f8a47f2b3 (diff) |
refactor: move `FileCollector` to deno_config (#24433)
Diffstat (limited to 'cli/util/sync')
-rw-r--r-- | cli/util/sync/atomic_flag.rs | 35 | ||||
-rw-r--r-- | cli/util/sync/mod.rs | 4 |
2 files changed, 2 insertions, 37 deletions
diff --git a/cli/util/sync/atomic_flag.rs b/cli/util/sync/atomic_flag.rs deleted file mode 100644 index 75396dcf4..000000000 --- a/cli/util/sync/atomic_flag.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -use std::sync::atomic::AtomicBool; -use std::sync::atomic::Ordering; - -/// Simplifies the use of an atomic boolean as a flag. -#[derive(Debug, Default)] -pub struct AtomicFlag(AtomicBool); - -impl AtomicFlag { - /// Raises the flag returning if the raise was successful. - pub fn raise(&self) -> bool { - !self.0.swap(true, Ordering::SeqCst) - } - - /// Gets if the flag is raised. - pub fn is_raised(&self) -> bool { - self.0.load(Ordering::SeqCst) - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn atomic_flag_raises() { - let flag = AtomicFlag::default(); - assert!(!flag.is_raised()); // false by default - assert!(flag.raise()); - assert!(flag.is_raised()); - assert!(!flag.raise()); - assert!(flag.is_raised()); - } -} diff --git a/cli/util/sync/mod.rs b/cli/util/sync/mod.rs index 28aab7f47..f58437503 100644 --- a/cli/util/sync/mod.rs +++ b/cli/util/sync/mod.rs @@ -1,14 +1,14 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. mod async_flag; -mod atomic_flag; mod sync_read_async_write_lock; mod task_queue; mod value_creator; pub use async_flag::AsyncFlag; -pub use atomic_flag::AtomicFlag; pub use sync_read_async_write_lock::SyncReadAsyncWriteLock; pub use task_queue::TaskQueue; pub use task_queue::TaskQueuePermit; pub use value_creator::MultiRuntimeAsyncValueCreator; +// todo(dsherret): this being in the unsync module is slightly confusing, but it's Sync +pub use deno_core::unsync::AtomicFlag; |