Simplify ARM run_enqueue
This commit is contained in:
		
							parent
							
								
									c6ca46c825
								
							
						
					
					
						commit
						889b419fc4
					
				@ -1,4 +1,3 @@
 | 
				
			|||||||
use core::arch::asm;
 | 
					 | 
				
			||||||
use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering};
 | 
					use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Clone, Copy)]
 | 
					#[derive(Clone, Copy)]
 | 
				
			||||||
@ -67,24 +66,10 @@ impl State {
 | 
				
			|||||||
    /// function if the task was successfully marked.
 | 
					    /// function if the task was successfully marked.
 | 
				
			||||||
    #[inline(always)]
 | 
					    #[inline(always)]
 | 
				
			||||||
    pub fn run_enqueue(&self, f: impl FnOnce(Token)) {
 | 
					    pub fn run_enqueue(&self, f: impl FnOnce(Token)) {
 | 
				
			||||||
        unsafe {
 | 
					        let old = self.run_queued.swap(true, Ordering::AcqRel);
 | 
				
			||||||
            loop {
 | 
					 | 
				
			||||||
                let state: u32;
 | 
					 | 
				
			||||||
                asm!("ldrex {}, [{}]", out(reg) state, in(reg) self, options(nostack));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if state & STATE_RUN_QUEUED != 0 {
 | 
					        if !old {
 | 
				
			||||||
                    asm!("clrex", options(nomem, nostack));
 | 
					            locked(f);
 | 
				
			||||||
                    return;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                let outcome: usize;
 | 
					 | 
				
			||||||
                let new_state = state | STATE_RUN_QUEUED;
 | 
					 | 
				
			||||||
                asm!("strex {}, {}, [{}]", out(reg) outcome, in(reg) new_state, in(reg) self, options(nostack));
 | 
					 | 
				
			||||||
                if outcome == 0 {
 | 
					 | 
				
			||||||
                    locked(f);
 | 
					 | 
				
			||||||
                    return;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user