mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 12:06:43 +00:00
Support T:?Sized as type parameter for Mutex, SpinLock, RwLock, and RwMutex
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
92a9f5616e
commit
dac41e9a2f
@ -10,7 +10,7 @@ pub mod driver;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{boxed::Box, collections::BTreeMap, string::String, sync::Arc, vec::Vec};
|
||||
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};
|
||||
use core::{any::Any, fmt::Debug};
|
||||
|
||||
use aster_frame::sync::SpinLock;
|
||||
@ -50,7 +50,7 @@ pub trait AnyNetworkDevice: Send + Sync + Any + Debug {
|
||||
|
||||
pub trait NetDeviceIrqHandler = Fn() + Send + Sync + 'static;
|
||||
|
||||
pub fn register_device(name: String, device: Arc<SpinLock<Box<dyn AnyNetworkDevice>>>) {
|
||||
pub fn register_device(name: String, device: Arc<SpinLock<dyn AnyNetworkDevice>>) {
|
||||
COMPONENT
|
||||
.get()
|
||||
.unwrap()
|
||||
@ -59,7 +59,7 @@ pub fn register_device(name: String, device: Arc<SpinLock<Box<dyn AnyNetworkDevi
|
||||
.insert(name, (Arc::new(SpinLock::new(Vec::new())), device));
|
||||
}
|
||||
|
||||
pub fn get_device(str: &str) -> Option<Arc<SpinLock<Box<dyn AnyNetworkDevice>>>> {
|
||||
pub fn get_device(str: &str) -> Option<Arc<SpinLock<dyn AnyNetworkDevice>>> {
|
||||
let lock = COMPONENT.get().unwrap().network_device_table.lock();
|
||||
let (_, device) = lock.get(str)?;
|
||||
Some(device.clone())
|
||||
@ -106,7 +106,7 @@ fn init() -> Result<(), ComponentInitError> {
|
||||
}
|
||||
|
||||
type NetDeviceIrqHandlerListRef = Arc<SpinLock<Vec<Arc<dyn NetDeviceIrqHandler>>>>;
|
||||
type NetworkDeviceRef = Arc<SpinLock<Box<dyn AnyNetworkDevice>>>;
|
||||
type NetworkDeviceRef = Arc<SpinLock<dyn AnyNetworkDevice>>;
|
||||
|
||||
struct Component {
|
||||
/// Device list, the key is device name, value is (callbacks, device);
|
||||
|
Reference in New Issue
Block a user