Skip to content

Commit

Permalink
Use libstd-provided OnceCell equivalent
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmooney committed Aug 4, 2023
1 parent 4b9314a commit f2f0ad2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ lazy_static = "1.4"
libc = "0.2"
mockall = "0.11"
num_enum = "0.5"
once_cell = "1.13"
proc-macro2 = "1.0"
progenitor = { git = "https://github.com/oxidecomputer/progenitor", branch = "main" }
quote = "1.0"
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Propolis works best (and its CI tests run) on AMD hosts, but it can also be used
to run VMs on Intel hosts. Live migration is primarily supported on AMD hosts
but may work on Intel hosts as well.

### Minimum Supported Rust Version (MSRV)

- Rust 1.67.0

## Building

To build, run:
Expand Down
2 changes: 1 addition & 1 deletion lib/propolis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "propolis"
version = "0.1.0"
license = "MPL-2.0"
edition = "2021"
rust-version = "1.70"

[dependencies]
libc.workspace = true
Expand All @@ -27,7 +28,6 @@ serde_arrays.workspace = true
erased-serde.workspace = true
serde_json.workspace = true
uuid.workspace = true
once_cell.workspace = true
crucible-client-types = { workspace = true, optional = true }
crucible = { workspace = true, optional = true }
oximeter = { workspace = true, optional = true }
Expand Down
19 changes: 9 additions & 10 deletions lib/propolis/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ use std::any::Any;
use std::collections::VecDeque;
use std::num::NonZeroUsize;
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::sync::{Arc, Condvar, Mutex, Weak};
use std::sync::{Arc, Condvar, Mutex, OnceLock, Weak};

use crate::accessors::{Guard as AccessorGuard, MemAccessor};
use crate::common::*;
use crate::tasks::*;
use crate::vmm::{MemCtx, SubMapping};

use futures::future::BoxFuture;
use once_cell::sync::OnceCell;
use tokio::sync::{Mutex as TokioMutex, Notify, Semaphore};

mod file;
Expand Down Expand Up @@ -420,8 +419,8 @@ impl Driver {
) -> Self {
Self {
inner: Arc::new(DriverInner {
bdev: OnceCell::new(),
acc_mem: OnceCell::new(),
bdev: OnceLock::new(),
acc_mem: OnceLock::new(),
queue: Mutex::new(VecDeque::new()),
cv: Condvar::new(),
idle_threads: Semaphore::new(0),
Expand Down Expand Up @@ -529,10 +528,10 @@ impl DriverCtrls {

struct DriverInner {
/// The block device providing the requests to be serviced
bdev: OnceCell<Arc<dyn Device>>,
bdev: OnceLock<Arc<dyn Device>>,

/// Memory accessor through the underlying device
acc_mem: OnceCell<MemAccessor>,
acc_mem: OnceLock<MemAccessor>,

/// Queue of I/O requests from the device ready to be serviced by the backend
queue: Mutex<VecDeque<Request>>,
Expand Down Expand Up @@ -738,13 +737,13 @@ impl WorkerHdl {

struct Inner {
/// The block device providing the requests to be serviced
bdev: OnceCell<Arc<dyn Device>>,
bdev: OnceLock<Arc<dyn Device>>,

/// Task control for work-scheduling task
sched_ctrl: Mutex<Option<TaskCtrl>>,

/// Memory accessor through the underlying device
acc_mem: OnceCell<MemAccessor>,
acc_mem: OnceLock<MemAccessor>,

/// Notifier used to both respond to the block frontend when it has requests
/// available for processing, as well as internally when waiting for workers
Expand All @@ -767,8 +766,8 @@ struct Inner {
impl Inner {
fn new() -> Arc<Self> {
Arc::new(Self {
bdev: OnceCell::new(),
acc_mem: OnceCell::new(),
bdev: OnceLock::new(),
acc_mem: OnceLock::new(),
sched_ctrl: Mutex::new(None),

queue: TokioMutex::new(VecDeque::new()),
Expand Down

0 comments on commit f2f0ad2

Please sign in to comment.