annotate
Tento commit je obsažen v:
rodič
1605934dbb
revize
a90cd5cc6b
@ -18,6 +18,7 @@ fn main() {
|
|||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
{
|
{
|
||||||
|
// in a subscope to release borrow automatically
|
||||||
let mut count = counter.lock().unwrap();
|
let mut count = counter.lock().unwrap();
|
||||||
*count += 1;
|
*count += 1;
|
||||||
}
|
}
|
||||||
@ -32,6 +33,7 @@ fn handle_connection(counter: Arc<Mutex<usize>>, mut stream: TcpStream) {
|
|||||||
stream.read(&mut buffer).unwrap();
|
stream.read(&mut buffer).unwrap();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// in a subscope to unlock automatically
|
||||||
let count = counter.lock().unwrap();
|
let count = counter.lock().unwrap();
|
||||||
println!("Request: {}\n{}", count, String::from_utf8_lossy(&buffer[..]));
|
println!("Request: {}\n{}", count, String::from_utf8_lossy(&buffer[..]));
|
||||||
}
|
}
|
||||||
|
|||||||
Načítá se…
x
Odkázat v novém úkolu
Zablokovat Uživatele