1
This commit is contained in:
parent
1add5d9388
commit
c22ee46299
@ -1,7 +1,7 @@
|
||||
use std::rc::{Rc, Weak};
|
||||
use std::cell::RefCell;
|
||||
use std::thread::sleep;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use std::time::Duration;
|
||||
use r9_macro::SharedFromSelf;
|
||||
use r9_macro_derive::SharedFromSelf;
|
||||
|
||||
@ -60,7 +60,7 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
while true {
|
||||
loop {
|
||||
crate::Timer::instance().borrow_mut().update();
|
||||
sleep(Duration::from_secs(1));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::rc::{Rc, Weak};
|
||||
use std::any::Any;
|
||||
use std::cell::RefCell;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::{Instant};
|
||||
use r9::xtimer::{TimerCb, XTimerWp, XTimerAttacherRp, TimerEvent};
|
||||
use r9_macro::SharedFromSelf;
|
||||
use r9_macro_derive::SharedFromSelf;
|
||||
|
@ -2,7 +2,7 @@ use std::rc::{Rc, Weak};
|
||||
use std::cell::RefCell;
|
||||
use std::any::Any;
|
||||
use std::cmp;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::{Instant};
|
||||
|
||||
use r9_macro::SharedFromSelf;
|
||||
use r9_macro_derive::SharedFromSelf;
|
||||
|
@ -15,5 +15,4 @@ pub trait SharedFromSelf {
|
||||
}
|
||||
|
||||
pub trait Singleton {
|
||||
fn instance() -> Rc::<RefCell::<Self>>;
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ pub fn singleton_derive(input: TokenStream) -> TokenStream {
|
||||
|
||||
fn impl_singleton_macro(ast: &syn::DeriveInput) -> TokenStream {
|
||||
let name = &ast.ident;
|
||||
let (impl_generics, _, _) = ast.generics.split_for_impl();
|
||||
let (_, _, _) = ast.generics.split_for_impl();
|
||||
let gen = quote! {
|
||||
impl #impl_generics Singleton for #name #impl_generics {
|
||||
fn instance() -> Rc::<RefCell::<Self>> {
|
||||
impl #name {
|
||||
pub fn instance() -> Rc::<RefCell::<Self>> {
|
||||
static mut _INSTANCE: Option<Rc::<RefCell::<#name>>> = None;
|
||||
unsafe {
|
||||
match &_INSTANCE {
|
||||
@ -63,5 +63,6 @@ fn impl_singleton_macro(ast: &syn::DeriveInput) -> TokenStream {
|
||||
}
|
||||
}
|
||||
};
|
||||
//println!("{}", gen);
|
||||
gen.into()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user