enable atomics and back to optimizing for speed

This commit is contained in:
Toshit Chawda 2024-02-04 12:06:51 -08:00
parent 54011e1f8a
commit 2158b9323e
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
10 changed files with 45 additions and 65 deletions

View file

@ -11,5 +11,6 @@ http-body-util = "0.1.0"
hyper = { version = "1.1.0", features = ["http1", "client"] }
tokio = { version = "1.36.0", features = ["full"] }
tokio-native-tls = "0.3.1"
tokio-util = "0.7.10"
wisp-mux = { path = "../wisp", features = ["fastwebsockets"]}

View file

@ -10,6 +10,7 @@ use std::{error::Error, future::Future};
use tokio::net::TcpStream;
use tokio_native_tls::{native_tls, TlsConnector};
use wisp_mux::{ClientMux, StreamType};
use tokio_util::either::Either;
#[derive(Debug)]
struct StrError(String);
@ -59,10 +60,18 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
.nth(4)
.ok_or(StrError::new("no dest port"))?
.parse()?;
let should_tls: bool = std::env::args()
.nth(5)
.ok_or(StrError::new("no should tls"))?
.parse()?;
let socket = TcpStream::connect(format!("{}:{}", &addr, addr_port)).await?;
let cx = TlsConnector::from(native_tls::TlsConnector::builder().build()?);
let socket = cx.connect(&addr, socket).await?;
let socket = if should_tls {
let cx = TlsConnector::from(native_tls::TlsConnector::builder().build()?);
Either::Left(cx.connect(&addr, socket).await?)
} else {
Either::Right(socket)
};
let req = Request::builder()
.method("GET")
.uri(format!("wss://{}:{}/", &addr, addr_port))