mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 12:36:46 +00:00
Implement Clone for IrqAllocateHandle
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
50c10653fb
commit
739eb30138
@ -39,7 +39,7 @@ pub struct IrqAllocateHandle {
|
|||||||
impl IrqAllocateHandle {
|
impl IrqAllocateHandle {
|
||||||
fn new(irq_num: u8) -> Self {
|
fn new(irq_num: u8) -> Self {
|
||||||
Self {
|
Self {
|
||||||
irq_num: irq_num,
|
irq_num,
|
||||||
irq: unsafe { IrqLine::acquire(irq_num) },
|
irq: unsafe { IrqLine::acquire(irq_num) },
|
||||||
callbacks: Vec::new(),
|
callbacks: Vec::new(),
|
||||||
}
|
}
|
||||||
@ -65,10 +65,22 @@ impl IrqAllocateHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Clone for IrqAllocateHandle {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
irq_num: self.irq_num.clone(),
|
||||||
|
irq: self.irq.clone(),
|
||||||
|
callbacks: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for IrqAllocateHandle {
|
impl Drop for IrqAllocateHandle {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
if Arc::strong_count(&self.irq) == 1 {
|
||||||
NOT_USING_IRQ.lock().dealloc(self.irq_num as usize);
|
NOT_USING_IRQ.lock().dealloc(self.irq_num as usize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ID_ALLOCATOR: Mutex<RecycleAllocator> = Mutex::new(RecycleAllocator::new());
|
static ID_ALLOCATOR: Mutex<RecycleAllocator> = Mutex::new(RecycleAllocator::new());
|
||||||
|
Reference in New Issue
Block a user