Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor codestyle fixes #52

Merged
merged 2 commits into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,9 +951,9 @@ impl Handle {
}
// The result has been collected, whether or not we were the caller that
// collected it. Return a reference.
match self.result.borrow().expect("result not filled") {
&Ok(ref output) => Ok(output),
&Err(ref err) => Err(clone_io_error(err)),
match *self.result.borrow().expect("result not filled") {
Ok(ref output) => Ok(output),
Err(ref err) => Err(clone_io_error(err)),
}
}

Expand Down Expand Up @@ -1217,7 +1217,7 @@ impl ThenHandle {
right_lock: Mutex::new(Some((right, context))),
right_cell: AtomicLazyCell::new(),
});
let clone = shared.clone();
let clone = Arc::clone(&shared);
let background_waiter = std::thread::spawn(move || {
Ok(clone.wait(WaitMode::Blocking)?.expect(
"blocking wait can't return None",
Expand Down Expand Up @@ -1341,7 +1341,7 @@ fn start_io(
match *io_inner {
Input(ref v) => {
return Ok(HandleInner::Input(Box::new(
InputHandle::start(expr_inner, context, v.clone())?,
InputHandle::start(expr_inner, context, Arc::clone(v))?,
)))
}
Stdin(ref p) => {
Expand Down Expand Up @@ -1539,12 +1539,12 @@ enum IoValue {

impl IoValue {
fn try_clone(&self) -> io::Result<IoValue> {
Ok(match self {
&IoValue::ParentStdin => IoValue::ParentStdin,
&IoValue::ParentStdout => IoValue::ParentStdout,
&IoValue::ParentStderr => IoValue::ParentStderr,
&IoValue::Null => IoValue::Null,
&IoValue::Handle(ref f) => IoValue::Handle(f.try_clone()?),
Ok(match *self {
IoValue::ParentStdin => IoValue::ParentStdin,
IoValue::ParentStdout => IoValue::ParentStdout,
IoValue::ParentStderr => IoValue::ParentStderr,
IoValue::Null => IoValue::Null,
IoValue::Handle(ref f) => IoValue::Handle(f.try_clone()?),
})
}

Expand Down Expand Up @@ -1804,8 +1804,7 @@ impl WaitMode {
// guaranteed to finish soon). Blocking waits should always join, even
// in the presence of errors.
match (self, expression_result) {
(&WaitMode::Blocking, _) => true,
(_, &Ok(Some(_))) => true,
(&WaitMode::Blocking, _) | (_, &Ok(Some(_))) => true,
_ => false,
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Musing unrelated to this fix:

This while should_join_background_thread concept feels really complicated now that I'm getting back to it :( I've been planning to get rid of the Then concept entirely, because of the complications like this that it creates, and it might be that then I can delete this whole thing...

Expand Down