Add critical-section around enqueuing of messages to an ActorContext.
@@ -102,7 +102,9 @@ impl<A: Actor> ActorContext<A> {
let notify: Box<dyn ActorFuture<A>> = Box::new(notify);
unsafe {
log::info!("enqueue notify");
+ cortex_m::interrupt::free(|cs| {
(&mut *self.items.get()).enqueue(notify).unwrap_or_else(|_| panic!("too many messages"));
+ });
let flag_ptr = (&*self.state_flag_handle.get()).unwrap() as *const AtomicU8;
log::info!("--> {:x}", flag_ptr as u32);
(*flag_ptr).store(ActorState::READY.into(), Ordering::Release);
@@ -121,7 +123,9 @@ impl<A: Actor> ActorContext<A> {
let request: Box<dyn ActorFuture<A>> = Box::new(request);
unsafe {
+ cortex_m::interrupt::free(|cs| {
(&mut *self.items.get()).enqueue(request).unwrap_or_else(|_| panic!("too many messages"));
+ });
let flag_ptr = (&*self.state_flag_handle.get()).unwrap() as *const AtomicU8;
(*flag_ptr).store(ActorState::READY.into(), Ordering::Release);
}
