diff --git a/Cargo.lock b/Cargo.lock index 4174b8b..d456343 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,25 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "libc" +version = "0.2.53" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "thread-priority" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "untitled" version = "0.1.0" +dependencies = [ + "thread-priority 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] +[metadata] +"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee" +"checksum thread-priority 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e655c097854cf47b40825a61c2edf7b96119ce9e02a9ff09e8b609b67f3c05e2" diff --git a/Cargo.toml b/Cargo.toml index 341d5f7..2b796a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,4 @@ authors = ["Michael Preisach "] edition = "2018" [dependencies] +thread-priority = "0.1.0" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4306097..a929a29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +extern crate thread_priority; +use thread_priority::*; use std::net::{TcpStream}; use std::io::prelude::*; use std::io::{BufReader}; @@ -11,6 +13,11 @@ use encoder::Encodestate; pub static DEBUG: bool = false; fn main() { + let thread_id = thread_native_id(); + assert!(set_thread_priority(thread_id, + ThreadPriority::Max, + ThreadSchedulePolicy::Realtime(RealtimeThreadSchedulePolicy::RoundRobin)).is_ok()); + let address = "192.168.1.77:8000"; let stream: TcpStream = TcpStream::connect(address).expect("connection failed"); let mut outstream = stream.try_clone().unwrap();