Skip to content

Commit 137561a

Browse files
committed
refactor(port_std): change check_preemption_by_interrupt not to mention State
1 parent fed2170 commit 137561a

File tree

1 file changed

+11
-8
lines changed
  • src/constance_port_std/src

1 file changed

+11
-8
lines changed

src/constance_port_std/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl ums::Scheduler for SchedState {
288288
/// [`ums::ThreadGroupLockGuard::preempt`] or [`ums::yield_now`].
289289
#[must_use]
290290
fn check_preemption_by_interrupt(
291-
state: &'static State,
291+
thread_group: &'static ums::ThreadGroup<SchedState>,
292292
lock: &mut ums::ThreadGroupLockGuard<SchedState>,
293293
) -> bool {
294294
let mut activated_any = false;
@@ -344,7 +344,7 @@ fn check_preemption_by_interrupt(
344344
// Safety: The port can call an interrupt handler
345345
unsafe { start() }
346346

347-
let mut lock = state.thread_group.get().unwrap().lock();
347+
let mut lock = thread_group.lock();
348348

349349
// Make this interrupt handler inactive
350350
let (_, popped_thread_id) = lock.scheduler().active_int_handlers.pop().unwrap();
@@ -358,7 +358,7 @@ fn check_preemption_by_interrupt(
358358
// Make sure this thread will run to completion
359359
lock.scheduler().zombies.push(thread_id);
360360

361-
let _ = check_preemption_by_interrupt(state, &mut lock);
361+
let _ = check_preemption_by_interrupt(thread_group, &mut lock);
362362
});
363363

364364
log::trace!(
@@ -427,7 +427,10 @@ impl State {
427427
lock.scheduler().cpu_lock = false;
428428

429429
// Start scheduling
430-
assert!(check_preemption_by_interrupt(self, &mut lock));
430+
assert!(check_preemption_by_interrupt(
431+
self.thread_group.get().unwrap(),
432+
&mut lock
433+
));
431434
lock.preempt();
432435
drop(lock);
433436

@@ -548,7 +551,7 @@ impl State {
548551
assert!(lock.scheduler().cpu_lock);
549552
lock.scheduler().cpu_lock = false;
550553

551-
if check_preemption_by_interrupt(self, &mut lock) {
554+
if check_preemption_by_interrupt(self.thread_group.get().unwrap(), &mut lock) {
552555
drop(lock);
553556
ums::yield_now();
554557
}
@@ -599,7 +602,7 @@ impl State {
599602
.update_line(num, |line| line.priority = priority)
600603
.map_err(|BadIntLineError| SetInterruptLinePriorityError::BadParam)?;
601604

602-
if check_preemption_by_interrupt(self, &mut lock) {
605+
if check_preemption_by_interrupt(self.thread_group.get().unwrap(), &mut lock) {
603606
drop(lock);
604607
ums::yield_now();
605608
}
@@ -618,7 +621,7 @@ impl State {
618621
.update_line(num, |line| line.enable = true)
619622
.map_err(|BadIntLineError| EnableInterruptLineError::BadParam)?;
620623

621-
if check_preemption_by_interrupt(self, &mut lock) {
624+
if check_preemption_by_interrupt(self.thread_group.get().unwrap(), &mut lock) {
622625
drop(lock);
623626
ums::yield_now();
624627
}
@@ -649,7 +652,7 @@ impl State {
649652
.update_line(num, |line| line.pended = true)
650653
.map_err(|BadIntLineError| PendInterruptLineError::BadParam)?;
651654

652-
if check_preemption_by_interrupt(self, &mut lock) {
655+
if check_preemption_by_interrupt(self.thread_group.get().unwrap(), &mut lock) {
653656
drop(lock);
654657
ums::yield_now();
655658
}

0 commit comments

Comments
 (0)