Browse Source

adding process priority

master
Michael Preisach 7 years ago
parent
commit
c32706e4af
  1. 10
      Cargo.lock
  2. 3
      Cargo.toml
  3. 7
      src/main.rs

10
Cargo.lock

@ -21,6 +21,7 @@ version = "0.1.0"
dependencies = [
"gpio 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rppal 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"thread-priority 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -32,8 +33,17 @@ dependencies = [
"libc 0.2.51 (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.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum gpio 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe6783270536547ac473c9d2ae5a7e0e715ea43f29004ced47fbd1c1372d2c7"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
"checksum rppal 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47fa3e09d34f2992f47f3d4315f8ee8cfffc1fe1912d4d08258b66cc18dc3b00"
"checksum thread-priority 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e655c097854cf47b40825a61c2edf7b96119ce9e02a9ff09e8b609b67f3c05e2"

3
Cargo.toml

@ -6,4 +6,5 @@ edition = "2018"
[dependencies]
rppal = "0.11.1"
gpio = "0.4.1"
gpio = "0.4.1"
thread-priority = "0.1.0"

7
src/main.rs

@ -1,3 +1,5 @@
extern crate thread_priority;
use thread_priority::*;
use std::net::{TcpStream, TcpListener};
use std::io::prelude::*;
use std::io::{BufReader, Result};
@ -61,6 +63,11 @@ fn handle_connection(stream: TcpStream, prot: &mut protocol::Protocol) -> Result
}
fn main() -> Result<()> {
let thread_id = thread_native_id();
assert!(set_thread_priority(thread_id,
ThreadPriority::Max,
ThreadSchedulePolicy::Realtime(RealtimeThreadSchedulePolicy::RoundRobin)).is_ok());
let address = "0.0.0.0:8000";
println!("Initialize network");
let listener = TcpListener::bind(address).expect("could not start server");

Loading…
Cancel
Save