Skip to content

Commit aa58bdf

Browse files
committed
feat(port_std): implement assert_current_thread again
1 parent 4bf4e34 commit aa58bdf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/constance_port_std/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ impl TaskState {
124124

125125
fn assert_current_thread(&self) {
126126
// `self` must represent the current thread
127-
// TODO
127+
let expected_thread_id = match &*self.tsm.lock() {
128+
Tsm::Running(thread_id) => *thread_id,
129+
_ => unreachable!(),
130+
};
131+
assert_eq!(ums::current_thread(), Some(expected_thread_id));
128132
}
129133

130134
unsafe fn exit_and_dispatch(&self, state: &'static State) -> ! {

src/constance_port_std/src/ums.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,8 @@ fn finalize_thread(
335335
// Invoke the scheduler
336336
state_guard.unpark_next_thread();
337337
}
338+
339+
/// Get the current worker thread.
340+
pub fn current_thread() -> Option<ThreadId> {
341+
TLB.with(|cell| cell.get().map(|tlb| tlb.thread_id))
342+
}

0 commit comments

Comments
 (0)