use identity hash function

This commit is contained in:
Toshit Chawda 2024-08-31 16:29:44 -07:00
parent 9cd87b7243
commit b70f91f90a
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
3 changed files with 13 additions and 4 deletions

7
Cargo.lock generated
View file

@ -1144,6 +1144,12 @@ dependencies = [
"getrandom", "getrandom",
] ]
[[package]]
name = "nohash-hasher"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@ -2258,6 +2264,7 @@ dependencies = [
"flume", "flume",
"futures", "futures",
"futures-timer", "futures-timer",
"nohash-hasher",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
] ]

View file

@ -17,6 +17,7 @@ fastwebsockets = { version = "0.8.0", features = ["unstable-split"], optional =
flume = "0.11.0" flume = "0.11.0"
futures = "0.3.30" futures = "0.3.30"
futures-timer = "3.0.3" futures-timer = "3.0.3"
nohash-hasher = "0.2.0"
pin-project-lite = "0.2.14" pin-project-lite = "0.2.14"
tokio = { version = "1.39.3", optional = true, default-features = false } tokio = { version = "1.39.3", optional = true, default-features = false }

View file

@ -1,17 +1,18 @@
use std::{ use std::{
collections::HashMap,
sync::{ sync::{
atomic::{AtomicBool, AtomicU32, Ordering}, atomic::{AtomicBool, AtomicU32, Ordering},
Arc, Arc,
}, },
}; };
use crate::{ use crate::{
extensions::AnyProtocolExtension, extensions::AnyProtocolExtension,
ws::{Frame, LockedWebSocketWrite, OpCode, Payload, WebSocketRead}, ws::{Frame, LockedWebSocketWrite, OpCode, Payload, WebSocketRead},
AtomicCloseReason, ClosePacket, CloseReason, ConnectPacket, MuxStream, Packet, PacketType, AtomicCloseReason, ClosePacket, CloseReason, ConnectPacket, MuxStream, Packet, PacketType,
Role, StreamType, WispError, Role, StreamType, WispError,
}; };
use nohash_hasher::IntMap;
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
use event_listener::Event; use event_listener::Event;
use flume as mpsc; use flume as mpsc;
@ -51,7 +52,7 @@ pub struct MuxInner<R: WebSocketRead + Send> {
fut_tx: mpsc::Sender<WsEvent>, fut_tx: mpsc::Sender<WsEvent>,
fut_exited: Arc<AtomicBool>, fut_exited: Arc<AtomicBool>,
stream_map: HashMap<u32, MuxMapValue>, stream_map: IntMap<u32, MuxMapValue>,
buffer_size: u32, buffer_size: u32,
target_buffer_size: u32, target_buffer_size: u32,
@ -91,7 +92,7 @@ impl<R: WebSocketRead + Send> MuxInner<R> {
role: Role::Server, role: Role::Server,
stream_map: HashMap::new(), stream_map: IntMap::default(),
server_tx, server_tx,
}, },
@ -127,7 +128,7 @@ impl<R: WebSocketRead + Send> MuxInner<R> {
role: Role::Client, role: Role::Client,
stream_map: HashMap::new(), stream_map: IntMap::default(),
server_tx, server_tx,
}, },