@@ -295,7 +295,7 @@ impl State {
295
295
296
296
pub unsafe fn dispatch_first_task < Traits : PortInstance > ( & ' static self ) -> ! {
297
297
log:: trace!( "dispatch_first_task" ) ;
298
- assert_eq ! ( expect_worker_thread:: < Traits > ( ) , ThreadRole :: Boot ) ;
298
+ assert_eq ! ( expect_worker_thread( ) , ThreadRole :: Boot ) ;
299
299
assert ! ( self . is_cpu_lock_active:: <Traits >( ) ) ;
300
300
301
301
// Create a UMS worker thread for the dispatcher
@@ -332,7 +332,7 @@ impl State {
332
332
}
333
333
334
334
fn dispatch < Traits : PortInstance > ( & ' static self ) {
335
- assert_eq ! ( expect_worker_thread:: < Traits > ( ) , ThreadRole :: Interrupt ) ;
335
+ assert_eq ! ( expect_worker_thread( ) , ThreadRole :: Interrupt ) ;
336
336
337
337
unsafe { self . enter_cpu_lock :: < Traits > ( ) } ;
338
338
unsafe { Traits :: choose_running_task ( ) } ;
@@ -387,7 +387,7 @@ impl State {
387
387
388
388
pub unsafe fn yield_cpu < Traits : PortInstance > ( & ' static self ) {
389
389
log:: trace!( "yield_cpu" ) ;
390
- expect_worker_thread :: < Traits > ( ) ;
390
+ expect_worker_thread ( ) ;
391
391
assert ! ( !self . is_cpu_lock_active:: <Traits >( ) ) ;
392
392
393
393
self . pend_interrupt_line :: < Traits > ( INTERRUPT_LINE_DISPATCH )
@@ -399,7 +399,7 @@ impl State {
399
399
task : & ' static TaskCb < Traits > ,
400
400
) -> ! {
401
401
log:: trace!( "exit_and_dispatch" ) ;
402
- assert_eq ! ( expect_worker_thread:: < Traits > ( ) , ThreadRole :: Task ) ;
402
+ assert_eq ! ( expect_worker_thread( ) , ThreadRole :: Task ) ;
403
403
assert ! ( self . is_cpu_lock_active:: <Traits >( ) ) ;
404
404
405
405
unsafe {
@@ -409,7 +409,7 @@ impl State {
409
409
410
410
pub unsafe fn enter_cpu_lock < Traits : PortInstance > ( & self ) {
411
411
log:: trace!( "enter_cpu_lock" ) ;
412
- expect_worker_thread :: < Traits > ( ) ;
412
+ expect_worker_thread ( ) ;
413
413
414
414
let mut lock = self . thread_group . get ( ) . unwrap ( ) . lock ( ) ;
415
415
assert ! ( !lock. scheduler( ) . cpu_lock) ;
@@ -418,7 +418,7 @@ impl State {
418
418
419
419
pub unsafe fn leave_cpu_lock < Traits : PortInstance > ( & ' static self ) {
420
420
log:: trace!( "leave_cpu_lock" ) ;
421
- expect_worker_thread :: < Traits > ( ) ;
421
+ expect_worker_thread ( ) ;
422
422
423
423
let mut lock = self . thread_group . get ( ) . unwrap ( ) . lock ( ) ;
424
424
assert ! ( lock. scheduler( ) . cpu_lock) ;
@@ -435,7 +435,7 @@ impl State {
435
435
task : & ' static TaskCb < Traits > ,
436
436
) {
437
437
log:: trace!( "initialize_task_state {task:p}" ) ;
438
- expect_worker_thread :: < Traits > ( ) ;
438
+ expect_worker_thread ( ) ;
439
439
assert ! ( self . is_cpu_lock_active:: <Traits >( ) ) ;
440
440
441
441
let pts = & task. port_task_state ;
@@ -452,15 +452,15 @@ impl State {
452
452
}
453
453
454
454
pub fn is_cpu_lock_active < Traits : PortInstance > ( & self ) -> bool {
455
- expect_worker_thread :: < Traits > ( ) ;
455
+ expect_worker_thread ( ) ;
456
456
457
457
( self . thread_group . get ( ) . unwrap ( ) . lock ( ) )
458
458
. scheduler ( )
459
459
. cpu_lock
460
460
}
461
461
462
462
pub fn is_task_context < Traits : PortInstance > ( & self ) -> bool {
463
- expect_worker_thread :: < Traits > ( ) ;
463
+ expect_worker_thread ( ) ;
464
464
465
465
THREAD_ROLE . with ( |role| match role. get ( ) {
466
466
ThreadRole :: Interrupt | ThreadRole :: Boot => false ,
@@ -470,7 +470,7 @@ impl State {
470
470
}
471
471
472
472
pub fn is_interrupt_context < Traits : PortInstance > ( & self ) -> bool {
473
- expect_worker_thread :: < Traits > ( ) ;
473
+ expect_worker_thread ( ) ;
474
474
475
475
THREAD_ROLE . with ( |role| match role. get ( ) {
476
476
ThreadRole :: Task | ThreadRole :: Boot => false ,
@@ -480,7 +480,7 @@ impl State {
480
480
}
481
481
482
482
pub fn is_scheduler_active < Traits : PortInstance > ( & self ) -> bool {
483
- expect_worker_thread :: < Traits > ( ) ;
483
+ expect_worker_thread ( ) ;
484
484
485
485
THREAD_ROLE . with ( |role| match role. get ( ) {
486
486
ThreadRole :: Interrupt | ThreadRole :: Task => true ,
@@ -496,7 +496,7 @@ impl State {
496
496
) -> Result < ( ) , SetInterruptLinePriorityError > {
497
497
log:: trace!( "set_interrupt_line_priority({num}, {priority})" ) ;
498
498
assert ! ( matches!(
499
- expect_worker_thread:: < Traits > ( ) ,
499
+ expect_worker_thread( ) ,
500
500
ThreadRole :: Boot | ThreadRole :: Task
501
501
) ) ;
502
502
@@ -518,7 +518,7 @@ impl State {
518
518
num : InterruptNum ,
519
519
) -> Result < ( ) , EnableInterruptLineError > {
520
520
log:: trace!( "enable_interrupt_line({num})" ) ;
521
- expect_worker_thread :: < Traits > ( ) ;
521
+ expect_worker_thread ( ) ;
522
522
523
523
let mut lock = self . thread_group . get ( ) . unwrap ( ) . lock ( ) ;
524
524
lock. scheduler ( )
@@ -538,7 +538,7 @@ impl State {
538
538
num : InterruptNum ,
539
539
) -> Result < ( ) , EnableInterruptLineError > {
540
540
log:: trace!( "disable_interrupt_line({num})" ) ;
541
- expect_worker_thread :: < Traits > ( ) ;
541
+ expect_worker_thread ( ) ;
542
542
543
543
( self . thread_group . get ( ) . unwrap ( ) . lock ( ) )
544
544
. scheduler ( )
@@ -551,7 +551,7 @@ impl State {
551
551
num : InterruptNum ,
552
552
) -> Result < ( ) , PendInterruptLineError > {
553
553
log:: trace!( "pend_interrupt_line({num})" ) ;
554
- expect_worker_thread :: < Traits > ( ) ;
554
+ expect_worker_thread ( ) ;
555
555
556
556
let mut lock = self . thread_group . get ( ) . unwrap ( ) . lock ( ) ;
557
557
lock. scheduler ( )
@@ -571,7 +571,7 @@ impl State {
571
571
num : InterruptNum ,
572
572
) -> Result < ( ) , ClearInterruptLineError > {
573
573
log:: trace!( "clear_interrupt_line({num})" ) ;
574
- expect_worker_thread :: < Traits > ( ) ;
574
+ expect_worker_thread ( ) ;
575
575
576
576
( self . thread_group . get ( ) . unwrap ( ) . lock ( ) )
577
577
. scheduler ( )
@@ -583,7 +583,7 @@ impl State {
583
583
& self ,
584
584
num : InterruptNum ,
585
585
) -> Result < bool , QueryInterruptLineError > {
586
- expect_worker_thread :: < Traits > ( ) ;
586
+ expect_worker_thread ( ) ;
587
587
588
588
( self . thread_group . get ( ) . unwrap ( ) . lock ( ) )
589
589
. scheduler ( )
@@ -596,7 +596,7 @@ impl State {
596
596
pub const MAX_TIMEOUT : UTicks = UTicks :: MAX / 2 ;
597
597
598
598
pub fn tick_count < Traits : PortInstance > ( & self ) -> UTicks {
599
- expect_worker_thread :: < Traits > ( ) ;
599
+ expect_worker_thread ( ) ;
600
600
601
601
let origin = if let Some ( x) = self . origin . load ( Ordering :: Acquire ) {
602
602
x
@@ -645,7 +645,7 @@ impl State {
645
645
}
646
646
647
647
pub fn pend_tick_after < Traits : PortInstance > ( & self , tick_count_delta : UTicks ) {
648
- expect_worker_thread :: < Traits > ( ) ;
648
+ expect_worker_thread ( ) ;
649
649
log:: trace!( "pend_tick_after({tick_count_delta:?})" ) ;
650
650
651
651
// Calculate when `timer_tick` should be called
@@ -663,15 +663,15 @@ impl State {
663
663
}
664
664
665
665
pub fn pend_tick < Traits : PortInstance > ( & ' static self ) {
666
- expect_worker_thread :: < Traits > ( ) ;
666
+ expect_worker_thread ( ) ;
667
667
log:: trace!( "pend_tick" ) ;
668
668
669
669
self . pend_interrupt_line :: < Traits > ( INTERRUPT_LINE_TIMER )
670
670
. unwrap ( ) ;
671
671
}
672
672
673
673
extern "C" fn timer_handler < Traits : PortInstance > ( ) {
674
- assert_eq ! ( expect_worker_thread:: < Traits > ( ) , ThreadRole :: Interrupt ) ;
674
+ assert_eq ! ( expect_worker_thread( ) , ThreadRole :: Interrupt ) ;
675
675
log:: trace!( "timer_handler" ) ;
676
676
677
677
// Safety: CPU Lock inactive, an interrupt context
@@ -680,7 +680,7 @@ impl State {
680
680
}
681
681
682
682
/// Assert that the current thread is a worker thread of `Traits`.
683
- fn expect_worker_thread < Traits : PortInstance > ( ) -> ThreadRole {
683
+ fn expect_worker_thread ( ) -> ThreadRole {
684
684
// TODO: Check that the current worker thread belongs to
685
685
// `Traits::port_state().thread_group`
686
686
let role = THREAD_ROLE . with ( |r| r. get ( ) ) ;
0 commit comments