1
This commit is contained in:
parent
28c89a6d50
commit
5726c3ad04
@ -9,15 +9,11 @@ use actix_web::{
|
||||
HttpServer,
|
||||
Error
|
||||
};
|
||||
use std::sync::{Arc};
|
||||
use tokio::sync::Mutex;
|
||||
use std::thread;
|
||||
use std::thread::JoinHandle;
|
||||
use actix::prelude::*;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use crate::app::UserApp;
|
||||
use crate::constant;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::runtime::Runtime;
|
||||
use crate::common::types::{DownStreamPack, DownStreamMessage, UpStreamPack};
|
||||
use std::sync::OnceLock;
|
||||
@ -28,13 +24,9 @@ struct AppStateWithCounter {
|
||||
}
|
||||
|
||||
pub struct WsListener {
|
||||
work_thread: Option<JoinHandle<()>>,
|
||||
socket_hash: std::sync::Mutex<HashMap<u16, Recipient<DownStreamMessage>>>,
|
||||
cur_socket_handle: AtomicU16,
|
||||
pub upstream: std::sync::Mutex<Option<std::sync::Arc<Mutex<TcpStream>>>>,
|
||||
tokio_rt: Runtime,
|
||||
down_pack_queue: Arc<std::sync::Mutex<r9::QueueLock<DownStreamPack>>>,
|
||||
up_pack_queue: Arc<std::sync::Mutex<r9::QueueLock<UpStreamPack>>>,
|
||||
}
|
||||
|
||||
static WsListenerInstance: OnceLock<WsListener> = OnceLock::new();
|
||||
@ -178,15 +170,11 @@ impl WsListener {
|
||||
pub fn new() -> Self {
|
||||
let p = Self{
|
||||
cur_socket_handle: AtomicU16::new(0),
|
||||
work_thread: Default::default(),
|
||||
socket_hash: Default::default(),
|
||||
upstream: Default::default(),
|
||||
tokio_rt: tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap(),
|
||||
down_pack_queue: r9::QueueLock::<DownStreamPack>::new_ex(),
|
||||
up_pack_queue: r9::QueueLock::<UpStreamPack>::new_ex(),
|
||||
};
|
||||
return p;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user