mirror of
https://github.com/storytold/point-generator.git
synced 2026-10-17 00:13:00 +00:00
faster
This commit is contained in:
+9
-11
@@ -33,7 +33,7 @@ fn main() {
|
|||||||
loop {
|
loop {
|
||||||
let point = Point::at_random_range(-1000.0f32, 1000.0f32, Color::Blue);
|
let point = Point::at_random_range(-1000.0f32, 1000.0f32, Color::Blue);
|
||||||
let bytes = point.to_bytes();
|
let bytes = point.to_bytes();
|
||||||
println!("Point : {}", point.debug_string());
|
//println!("Point : {}", point.debug_string());
|
||||||
|
|
||||||
if reconnect {
|
if reconnect {
|
||||||
socket = reconnect_socket(&context, socket, SOCKET_ADDRESS);
|
socket = reconnect_socket(&context, socket, SOCKET_ADDRESS);
|
||||||
@@ -43,38 +43,36 @@ fn main() {
|
|||||||
|
|
||||||
match messaging_state {
|
match messaging_state {
|
||||||
MessagingState::Sending => {
|
MessagingState::Sending => {
|
||||||
|
//println!("Sending request...");
|
||||||
println!("Sending request...");
|
|
||||||
//let result = socket.send("hello world!", 0);
|
//let result = socket.send("hello world!", 0);
|
||||||
let result = socket.send(&bytes, 0);
|
let result = socket.send(&bytes, 0);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Sent!");
|
//println!("Sent!");
|
||||||
thread::sleep(Duration::from_millis(250));
|
//thread::sleep(Duration::from_millis(250));
|
||||||
messaging_state = MessagingState::Receiving;
|
messaging_state = MessagingState::Receiving;
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Send Error: {:?}", e);
|
eprintln!("Send Error: {:?}", e);
|
||||||
thread::sleep(Duration::from_millis(2000));
|
thread::sleep(Duration::from_millis(250));
|
||||||
fail_count += 1;
|
fail_count += 1;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
MessagingState::Receiving => {
|
MessagingState::Receiving => {
|
||||||
|
//println!("Awaiting response...");
|
||||||
println!("Awaiting response...");
|
|
||||||
let result = socket.recv_bytes(DONTWAIT);
|
let result = socket.recv_bytes(DONTWAIT);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Response received!");
|
//println!("Response received!");
|
||||||
messaging_state = MessagingState::Sending;
|
messaging_state = MessagingState::Sending;
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("Recv Error: {:?}", e);
|
eprintln!("Recv Error: {:?}", e);
|
||||||
thread::sleep(Duration::from_millis(2000));
|
thread::sleep(Duration::from_millis(250));
|
||||||
fail_count += 1;
|
fail_count += 1;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -85,7 +83,7 @@ fn main() {
|
|||||||
if fail_count > 5 {
|
if fail_count > 5 {
|
||||||
reconnect = true;
|
reconnect = true;
|
||||||
fail_count = 0;
|
fail_count = 0;
|
||||||
thread::sleep(Duration::from_millis(5000));
|
thread::sleep(Duration::from_millis(2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user