Skip to content

Commit

Permalink
fix: borrow_mut error in future.rs (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jul 4, 2024
1 parent cb48b28 commit 81324e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_unsync"
version = "0.3.5"
version = "0.3.6"
edition = "2021"
authors = ["the Deno authors"]
license = "MIT"
Expand Down
22 changes: 12 additions & 10 deletions src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ where
let mut inner = self.0.data.borrow_mut();
match &mut inner.future_or_output {
FutureOrOutput::Future(fut) => {
self
.0
.child_waker_state
.wakers
.borrow_mut()
.push(cx.waker().clone());
{
let mut wakers = self.0.child_waker_state.wakers.borrow_mut();
wakers.push(cx.waker().clone());
}
if self.0.child_waker_state.can_poll.lower() {
let child_waker =
create_child_waker(self.0.child_waker_state.clone());
Expand All @@ -141,9 +139,10 @@ where
Poll::Ready(result) => {
inner.future_or_output = FutureOrOutput::Output(result.clone());
drop(inner); // stop borrow_mut
let wakers = std::mem::take(
&mut *self.0.child_waker_state.wakers.borrow_mut(),
);
let wakers = {
let mut wakers = self.0.child_waker_state.wakers.borrow_mut();
std::mem::take(&mut *wakers)
};
for waker in wakers {
waker.wake();
}
Expand Down Expand Up @@ -207,7 +206,10 @@ unsafe fn wake_waker(data: *const ()) {
unsafe fn wake_by_ref_waker(data: *const ()) {
let state = Rc::from_raw(data as *const ChildWakerState);
state.can_poll.raise();
let wakers = state.wakers.borrow().clone();
let wakers = {
let wakers = state.wakers.borrow();
wakers.clone()
};
for waker in wakers {
waker.wake_by_ref();
}
Expand Down

0 comments on commit 81324e4

Please sign in to comment.