[mio] 调整代码
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use std::net::{Ipv4Addr, SocketAddr};
|
||||
|
||||
pub mod callback;
|
||||
@@ -201,3 +202,16 @@ impl CurrentDeviceInfo {
|
||||
&self.virtual_gateway == ip || ip == &GATEWAY_IP
|
||||
}
|
||||
}
|
||||
pub fn change_status(
|
||||
current_device: &AtomicCell<CurrentDeviceInfo>,
|
||||
connect_status: ConnectStatus,
|
||||
) -> CurrentDeviceInfo {
|
||||
loop {
|
||||
let cur = current_device.load();
|
||||
let mut new_info = cur;
|
||||
new_info.status = connect_status;
|
||||
if current_device.compare_exchange(cur, new_info).is_ok() {
|
||||
return new_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user