Refactor Rwlock to take type parameter

This commit is contained in:
jiangjianfeng
2024-11-19 10:35:20 +00:00
committed by Tate, Hongliang Tian
parent ac1a6be05d
commit 495c93c2ad
20 changed files with 205 additions and 363 deletions

View File

@ -46,7 +46,7 @@ pub struct BoundSocketInner<T, E> {
iface: Arc<dyn Iface<E>>,
port: u16,
socket: T,
observer: RwLock<Weak<dyn SocketEventObserver>>,
observer: RwLock<Weak<dyn SocketEventObserver>, LocalIrqDisabled>,
events: AtomicU8,
next_poll_at_ms: AtomicU64,
}
@ -223,7 +223,7 @@ impl<T: AnySocket, E> BoundSocket<T, E> {
/// that the old observer will never be called after the setting. Users should be aware of this
/// and proactively handle the race conditions if necessary.
pub fn set_observer(&self, new_observer: Weak<dyn SocketEventObserver>) {
*self.0.observer.write_irq_disabled() = new_observer;
*self.0.observer.write() = new_observer;
self.0.on_events();
}