mod.rs 692 Bytes
Newer Older
1
2
3
4
5
6
7
// Copyright (c) 2019 Stefan Lankes, RWTH Aachen University
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

8
use crate::synch::semaphore::*;
9

10
static NET_SEM: Semaphore = Semaphore::new(0);
11

12
pub fn netwakeup() {
13
	NET_SEM.release();
14
}
Stefan Lankes's avatar
Stefan Lankes committed
15

16
pub fn netwait(millis: Option<u64>) {
17
18
19
	match millis {
		Some(ms) => {
			if ms > 0 {
20
				NET_SEM.acquire(Some(ms));
21
22
23
24
25
26
27
28
			} else {
				NET_SEM.try_acquire();
			}
		}
		_ => {
			NET_SEM.acquire(None);
		}
	};
29
}