1
This commit is contained in:
parent
7eed540867
commit
79cfc8120e
@ -6,10 +6,10 @@ use r9_macro_derive::SharedFromSelf;
|
||||
#[derive(Default)]
|
||||
#[derive(SharedFromSelf)]
|
||||
pub struct ListHead<T> {
|
||||
prev: Weak::<RefCell::<ListHead<T>>>,
|
||||
next: Weak::<RefCell::<ListHead<T>>>,
|
||||
prev: Weak::<RefCell::<Self>>,
|
||||
next: Weak::<RefCell::<Self>>,
|
||||
data: Weak::<RefCell::<T>>,
|
||||
_self_wp: Weak::<RefCell::<ListHead<T>>>,
|
||||
_self_wp: Weak::<RefCell::<Self>>,
|
||||
}
|
||||
|
||||
impl<T> ListHead<T> {
|
||||
|
16
src/timer.rs
16
src/timer.rs
@ -2,6 +2,8 @@ use std::rc::{Rc, Weak};
|
||||
use std::cell::RefCell;
|
||||
use std::any::Any;
|
||||
use std::cmp;
|
||||
use r9_macro::SharedFromSelf;
|
||||
use r9_macro_derive::SharedFromSelf;
|
||||
|
||||
/*
|
||||
use proc_macro::TokenStream;
|
||||
@ -49,7 +51,6 @@ impl Default for TimerType {
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
//#[derive(crate::EnableSharedFromSelf)]
|
||||
pub struct TimerList {
|
||||
holder: TimerListRp,
|
||||
wp: Rc::<TimerListRp>,
|
||||
@ -62,6 +63,7 @@ pub struct TimerList {
|
||||
cb: Option<TimerCb>,
|
||||
}
|
||||
|
||||
#[derive(SharedFromSelf)]
|
||||
pub struct Timer {
|
||||
free_timer_num: i32,
|
||||
free_timer_list: TimerListListHeadRp,
|
||||
@ -75,6 +77,7 @@ pub struct Timer {
|
||||
tv3: [TimerListListHeadRp; TVN_SIZE],
|
||||
tv4: [TimerListListHeadRp; TVN_SIZE],
|
||||
tv5: [TimerListListHeadRp; TVN_SIZE],
|
||||
_self_wp: Weak::<RefCell::<Self>>,
|
||||
}
|
||||
|
||||
impl Timer {
|
||||
@ -130,17 +133,6 @@ impl Timer {
|
||||
for_each_cb(&mut self.tv5);
|
||||
}
|
||||
|
||||
fn shared_from_self(&self) -> Rc::<RefCell::<Timer>> {
|
||||
//let cell_rc: &Rc<RefCell<Timer> = &self ;
|
||||
//let head: &ListHead<T> = &*cell_rc.borrow();
|
||||
let cell_start = 0 as *const u8;
|
||||
//let data_start = head as *const ListHead<T> as *const u8;
|
||||
//let cell_offset = unsafe { data_start.offset_from(cell_start) };
|
||||
unsafe {
|
||||
return Rc::from_raw(cell_start as *const RefCell::<Timer>);
|
||||
};
|
||||
}
|
||||
|
||||
pub fn uninit(&mut self) {
|
||||
self.clear();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user