1
This commit is contained in:
parent
cba1ec0d84
commit
d7b39fee44
@ -54,8 +54,11 @@ impl f9::app::UserApp for UserApp {
|
||||
|
||||
fn update(&mut self) {
|
||||
self.net_msg_queue.borrow_mut().fetch();
|
||||
if self.net_msg_queue.borrow_mut().empty() {
|
||||
|
||||
let work_list = self.net_msg_queue.borrow_mut().work_list.clone();
|
||||
while !work_list.borrow().empty() {
|
||||
println!("work_list exec");
|
||||
let node = &work_list.borrow().first_entry();
|
||||
node.upgrade().unwrap().borrow_mut().entry.borrow_mut().del_init();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ use actix::prelude::*;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use actix_web::web::Bytes;
|
||||
use crate::app::UserApp;
|
||||
use crate::{GSResponse, MAX_PACKET_LEN};
|
||||
use crate::{AppStateWithCounter, GSResponse, MAX_PACKET_LEN};
|
||||
|
||||
#[derive(SharedFromSelf)]
|
||||
#[derive(Singleton)]
|
||||
@ -184,21 +184,25 @@ impl WsListener {
|
||||
//self.work_thread = Arc::new(Some(1));
|
||||
{
|
||||
self.work_thread = Some(thread::spawn(|| {
|
||||
println!("hello2");
|
||||
let mut rt = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async {
|
||||
let counter = web::Data::new(AppStateWithCounter {
|
||||
counter: Mutex::new(0),
|
||||
});
|
||||
HttpServer::new(move || {
|
||||
// move counter into the closure
|
||||
ActixApp::new() // <- register the created data
|
||||
.route("/", web::get().to(crate::index))
|
||||
.app_data(counter.clone())
|
||||
.route("/", web::get().to(index))
|
||||
})
|
||||
.bind(("0.0.0.0", 8080))?
|
||||
.run()
|
||||
.await
|
||||
});
|
||||
println!("hello2");
|
||||
}));
|
||||
println!("hello3");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user