Skip to content

Commit

Permalink
make format
Browse files Browse the repository at this point in the history
Signed-off-by: Connor1996 <[email protected]>
  • Loading branch information
Connor1996 committed Aug 31, 2023
1 parent 928dd70 commit 6754299
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ where
) -> Result<Engine<F, FilePipeLog<F>>> {
Engine::open_with(cfg, file_system, vec![])
}

fn open_with(
mut cfg: Config,
file_system: Arc<F>,
Expand Down
18 changes: 11 additions & 7 deletions src/env/double_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use std::path::PathBuf;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;
use std::sync::Mutex;
use std::thread;

use crate::env::default::LogFd;
use crate::env::DefaultFileSystem;
Expand Down Expand Up @@ -93,8 +93,8 @@ fn replace_path(path: &Path, from: &Path, to: &Path) -> PathBuf {
}
}


// Make sure the task is sent to two disks' channel atomically, otherwise the ordering of the tasks in two disks are not same.
// Make sure the task is sent to two disks' channel atomically, otherwise the
// ordering of the tasks in two disks are not same.
#[derive(Clone)]
struct HedgedSender(Arc<Mutex<HedgedSenderInner>>);

Expand All @@ -104,7 +104,10 @@ struct HedgedSenderInner {
}

impl HedgedSender {
fn new(disk1: Sender<(Task, Callback<TaskRes>)>, disk2: Sender<(Task, Callback<TaskRes>)>) -> Self {
fn new(
disk1: Sender<(Task, Callback<TaskRes>)>,
disk2: Sender<(Task, Callback<TaskRes>)>,
) -> Self {
Self(Arc::new(Mutex::new(HedgedSenderInner { disk1, disk2 })))
}

Expand Down Expand Up @@ -380,7 +383,7 @@ impl HedgedFileSystem {
async fn wait_one(&self, task1: Task, task2: Task) -> IoResult<()> {
let (cb1, mut f1) = paired_future_callback();
let (cb2, mut f2) = paired_future_callback();
self.sender.send(task1, task2, cb1, cb2) ;
self.sender.send(task1, task2, cb1, cb2);

select! {
res1 = f1 => res1.unwrap().map(|_| ()),
Expand Down Expand Up @@ -425,7 +428,8 @@ impl HedgedFileSystem {

impl Drop for HedgedFileSystem {
fn drop(&mut self) {
self.sender.send(Task::Stop, Task::Stop, Box::new(|_| {}), Box::new(|_| {}));
self.sender
.send(Task::Stop, Task::Stop, Box::new(|_| {}), Box::new(|_| {}));
self.handle1.take().unwrap().join().unwrap();
self.handle2.take().unwrap().join().unwrap();
}
Expand Down Expand Up @@ -692,7 +696,7 @@ impl HedgedHandle {
async fn wait_one(&self, task1: Task, task2: Task) -> IoResult<TaskRes> {
let (cb1, mut f1) = paired_future_callback();
let (cb2, mut f2) = paired_future_callback();
self.sender.send(task1, task2, cb1, cb2) ;
self.sender.send(task1, task2, cb1, cb2);

select! {
res1 = f1 => res1.unwrap(),
Expand Down

0 comments on commit 6754299

Please sign in to comment.