1
This commit is contained in:
parent
bf7c30e822
commit
3a2b95dfc9
@ -159,7 +159,7 @@ impl App {
|
|||||||
pub fn init(user_app: Rc::<RefCell::<dyn UserApp>>) {
|
pub fn init(user_app: Rc::<RefCell::<dyn UserApp>>) {
|
||||||
App::instance().borrow_mut().user_app = Some(user_app.clone());
|
App::instance().borrow_mut().user_app = Some(user_app.clone());
|
||||||
App::instance().borrow_mut().tokio_rt.enter();
|
App::instance().borrow_mut().tokio_rt.enter();
|
||||||
App::instance().borrow_mut().init_http_server();
|
//App::instance().borrow_mut().init_http_server();
|
||||||
crate::Timer::instance().borrow_mut().init();
|
crate::Timer::instance().borrow_mut().init();
|
||||||
user_app.borrow_mut().init();
|
user_app.borrow_mut().init();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::sync::Mutex;
|
||||||
use r9_macro::SharedFromSelf;
|
use r9_macro::SharedFromSelf;
|
||||||
use r9_macro_derive::SharedFromSelf;
|
use r9_macro_derive::SharedFromSelf;
|
||||||
|
|
||||||
#[derive(SharedFromSelf)]
|
#[derive(SharedFromSelf)]
|
||||||
pub struct Queue<T> {
|
pub struct Queue<T> {
|
||||||
msg_list: Rc::<RefCell::<crate::ListHead<T>>>,
|
msg_list: Mutex<Rc::<RefCell::<crate::ListHead<T>>>>,
|
||||||
pub work_list: Rc::<RefCell::<crate::ListHead<T>>>,
|
pub work_list: Rc::<RefCell::<crate::ListHead<T>>>,
|
||||||
_self_wp: Weak::<RefCell::<Self>>,
|
_self_wp: Weak::<RefCell::<Self>>,
|
||||||
}
|
}
|
||||||
@ -14,7 +15,7 @@ impl<T> Queue<T> {
|
|||||||
|
|
||||||
pub fn new() -> Rc::<RefCell::<Self>> {
|
pub fn new() -> Rc::<RefCell::<Self>> {
|
||||||
let this = Rc::new(RefCell::new(Self{
|
let this = Rc::new(RefCell::new(Self{
|
||||||
msg_list: crate::ListHead::<T>::new_head(),
|
msg_list: Mutex::new(crate::ListHead::<T>::new_head()),
|
||||||
work_list: crate::ListHead::<T>::new_head(),
|
work_list: crate::ListHead::<T>::new_head(),
|
||||||
_self_wp: Default::default(),
|
_self_wp: Default::default(),
|
||||||
}));
|
}));
|
||||||
@ -23,13 +24,13 @@ impl<T> Queue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&self, node: &Rc::<RefCell::<crate::ListHead<T>>>) {
|
pub fn push(&self, node: &Rc::<RefCell::<crate::ListHead<T>>>) {
|
||||||
crate::ListHead::<T>::add_tail(&self.msg_list, node);
|
crate::ListHead::<T>::add_tail(&self.msg_list.lock().unwrap(), node);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch(&self) {
|
pub fn fetch(&self) {
|
||||||
if !self.msg_list.borrow().empty() &&
|
if !self.msg_list.lock().unwrap().borrow().empty() &&
|
||||||
self.work_list.borrow().empty() {
|
self.work_list.borrow().empty() {
|
||||||
crate::ListHead::replace_init(&self.work_list, &self.msg_list);
|
crate::ListHead::replace_init(&self.work_list, &self.msg_list.lock().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ impl<T> Queue<T> {
|
|||||||
if !self.work_list.borrow().empty() {
|
if !self.work_list.borrow().empty() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return self.msg_list.borrow().empty()
|
return self.msg_list.lock().unwrap().borrow().empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user