Skip to content

Commit

Permalink
Fix the drop order problem and improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
charypar committed Aug 9, 2024
1 parent cd10b0d commit 8c21072
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crux_core/src/capability/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Spawner {

self.task_sender
.send(task)
.expect("to be able to send tasks on an unbounded queue")
.expect("unable to spawn an async task, task sender channel is disconnected.")
}
}
// ANCHOR_END: spawning
Expand All @@ -65,7 +65,7 @@ impl ArcWake for Task {
arc_self
.task_sender
.send(cloned)
.expect("to be able to send tasks on an unbounded queue")
.expect("unable to wake an async task, task sender channel is disconnected.")
}
}
// ANCHOR_END: arc_wake
Expand Down
12 changes: 10 additions & 2 deletions crux_core/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ pub struct Core<Ef, A>
where
A: App,
{
// WARNING: The user controlled types _must_ be defined first
// so that they are dropped first, in case they contain coordination
// primitives which attempt to wake up a future when dropped. For that
// reason the executor _must_ outlive the user type instances

// user types
model: RwLock<A::Model>,
executor: QueuingExecutor,
capabilities: A::Capabilities,
app: A,

// internals
requests: Receiver<Ef>,
capability_events: Receiver<A::Event>,
app: A,
executor: QueuingExecutor,
}
// ANCHOR_END: core

Expand Down

0 comments on commit 8c21072

Please sign in to comment.