This commit is contained in:
azw 2024-05-12 18:01:36 +08:00
parent b5fb7cb0e8
commit 58fa1b92e5

View File

@ -6,7 +6,7 @@ use crate::common::types::DownStreamPack;
use std::sync::OnceLock;
pub struct UserApp {
net_msg_queue: Arc::<std::sync::Mutex::<r9::QueueLock<DownStreamPack>>>,
down_stream_msg_queue: Arc::<std::sync::Mutex::<r9::QueueLock<DownStreamPack>>>,
}
impl f9::app::UserApp for UserApp {
@ -66,20 +66,20 @@ impl UserApp {
}
pub fn new() -> Self {
let p = UserApp{
net_msg_queue: r9::QueueLock::<DownStreamPack>::new(),
down_stream_msg_queue: r9::QueueLock::<DownStreamPack>::new(),
};
return p;
}
fn fetch_work_list(&self) -> Arc::<Mutex::<r9::ListHeadLock<DownStreamPack>>> {
self.net_msg_queue.lock().unwrap().fetch();
return self.net_msg_queue.lock().unwrap().work_list.lock().unwrap().clone();
self.down_stream_msg_queue.lock().unwrap().fetch();
return self.down_stream_msg_queue.lock().unwrap().work_list.lock().unwrap().clone();
}
pub fn add_down_stream_pack(&self, socket_handle: u16, data: bytes::BytesMut) {
println!("add_down_stream_pack1 len:{0}", data.len());
let node = DownStreamPack::new(socket_handle, data);
self.net_msg_queue.lock().unwrap().push(&node.lock().unwrap().entry);
self.down_stream_msg_queue.lock().unwrap().push(&node.lock().unwrap().entry);
}
}