Pārlūkot izejas kodu

ntex, fix platform bench (#7077)

Nikolay Kim 3 gadi atpakaļ
vecāks
revīzija
91cc6c0f76
2 mainītis faili ar 28 papildinājumiem un 26 dzēšanām
  1. 1 1
      frameworks/Rust/ntex/Cargo.toml
  2. 27 25
      frameworks/Rust/ntex/src/main_plt.rs

+ 1 - 1
frameworks/Rust/ntex/Cargo.toml

@@ -37,7 +37,7 @@ tokio = ["ntex/tokio"]
 async-std = ["ntex/async-std"]
 
 [dependencies]
-ntex = "0.5.8"
+ntex = "0.5.14"
 mimalloc = { version = "0.1.25", default-features = false }
 snmalloc-rs = { version = "0.2.26", features = ["1mib", "native-cpu"] }
 yarte = { version = "0.15", features = ["bytes-buf", "json"] }

+ 27 - 25
frameworks/Rust/ntex/src/main_plt.rs

@@ -37,33 +37,35 @@ impl Future for App {
             match ready!(this.io.poll_recv(&this.codec, cx)) {
                 Ok((req, _)) => {
                     let _ = this.io.with_write_buf(|buf| {
-                        // make sure we've got room
-                        let remaining = buf.remaining_mut();
-                        if remaining < 1024 {
-                            buf.reserve(65535 - remaining);
-                        }
-
-                        match req.path() {
-                            "/json" => {
-                                buf.extend_from_slice(JSON);
-                                this.codec.set_date_header(buf);
-                                let _ = simd_json::to_writer(
-                                    crate::utils::Writer(buf),
-                                    &Message {
-                                        message: "Hello, World!",
-                                    },
-                                );
-                            }
-                            "/plaintext" => {
-                                buf.extend_from_slice(PLAIN);
-                                this.codec.set_date_header(buf);
-                                buf.extend_from_slice(BODY);
+                        buf.with_bytes_mut(|buf| {
+                            // make sure we've got room
+                            let remaining = buf.remaining_mut();
+                            if remaining < 1024 {
+                                buf.reserve(65535 - remaining);
                             }
-                            _ => {
-                                buf.extend_from_slice(HTTPNFOUND);
-                                buf.extend_from_slice(HDR_SERVER);
+
+                            match req.path() {
+                                "/json" => {
+                                    buf.extend_from_slice(JSON);
+                                    this.codec.set_date_header(buf);
+                                    let _ = simd_json::to_writer(
+                                        crate::utils::Writer(buf),
+                                        &Message {
+                                            message: "Hello, World!",
+                                        },
+                                    );
+                                }
+                                "/plaintext" => {
+                                    buf.extend_from_slice(PLAIN);
+                                    this.codec.set_date_header(buf);
+                                    buf.extend_from_slice(BODY);
+                                }
+                                _ => {
+                                    buf.extend_from_slice(HTTPNFOUND);
+                                    buf.extend_from_slice(HDR_SERVER);
+                                }
                             }
-                        }
+                        })
                     });
                 }
                 Err(RecvError::WriteBackpressure) => {