Skip to content

Commit

Permalink
fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jimy-byerley committed Oct 19, 2023
1 parent dbe5164 commit 2d0613f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/rawmaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
*/

use std::{
sync::{Arc, Mutex, Condvar},
os::fd::AsRawFd,
sync::{Arc, Mutex},
time::Instant,
};
use core::{
ops::DerefMut,
time::Duration,
};
use tokio::{
io::unix::AsyncFd,
task::JoinHandle,
sync::Notify,
};
use tokio_timerfd::{Delay, Interval};
use bilge::prelude::*;
use futures_concurrency::future::{Join, Race};
use futures_concurrency::future::Race;
use futures::StreamExt;
use core::future::poll_fn;

Expand Down Expand Up @@ -87,7 +85,6 @@ pub struct RawMaster {
// they should not be held for too long (and never during blocking operations) so they shouldn't disturb the async runtime too much

pdu_state: Mutex<PduState>,
ethercat_receive: Mutex<[u8; MAX_ETHERCAT_FRAME]>,
task: Mutex<Option<JoinHandle<()>>>,
}
struct PduState {
Expand All @@ -110,7 +107,7 @@ struct PduStorage {
}
impl RawMaster {
pub fn new<S: EthercatSocket + 'static + Send + Sync>(socket: S) -> Arc<Self> {
let mut master = Arc::new(Self {
let master = Arc::new(Self {
pdu_merge_time: std::time::Duration::from_micros(100),

socket: Box::new(socket),
Expand All @@ -126,7 +123,6 @@ impl RawMaster {
receive: [0; 2*MAX_ETHERCAT_PDU].map(|_| None),
free: (0 .. 2*MAX_ETHERCAT_PDU).collect(),
}),
ethercat_receive: Mutex::new([0; MAX_ETHERCAT_FRAME]),
task: Mutex::new(None),
});
master.task.lock().unwrap().replace(tokio::task::spawn({
Expand Down Expand Up @@ -466,10 +462,10 @@ impl RawMaster {
async fn task_send(&self) -> EthercatResult {
let mut delay = Delay::new(Instant::now())?;
loop {
let mut delay = &mut delay;
let delay = &mut delay;

// wait indefinitely if no data to send
let mut ready = loop {
let ready = loop {
self.sendable.notified().await;
let state = self.pdu_state.lock().unwrap();
if state.last_end != 0 {break state.ready}
Expand All @@ -486,7 +482,7 @@ impl RawMaster {
// timeout for sending the batch
async {
delay.await.unwrap();
/// TODO: handle the possible ioerror in the delay
// TODO: handle the possible ioerror in the delay
let mut state = self.pdu_state.lock().unwrap();
state.ready = true;
state
Expand Down
1 change: 0 additions & 1 deletion src/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ mod ethernet;

pub use udp::UdpSocket;
pub use ethernet::EthernetSocket;
use core::future::Future;
use core::task::{Poll, Context};

use std::io;
Expand Down
2 changes: 1 addition & 1 deletion src/socket/udp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::io::{self, Result, Error};
use std::io::Result;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};
use std::os::fd::{AsRawFd, RawFd};
use core::task::{Poll, Context};
Expand Down

0 comments on commit 2d0613f

Please sign in to comment.