Update to new fevent

This commit is contained in:
Jeremy Soller
2019-03-13 14:08:44 -06:00
parent d9b9c7158d
commit 2ef4408a7a
8 changed files with 43 additions and 55 deletions
+14 -13
View File
@@ -98,29 +98,30 @@ impl Resource for PtyMaster {
}
}
fn fevent(&mut self) -> Result<()> {
fn fevent(&mut self) -> Result<usize> {
self.notified_read = false; // resend
self.notified_write = false;
Ok(())
Ok(self.events())
}
fn fevent_count(&mut self) -> Option<usize> {
fn events(&mut self) -> usize {
let mut events = 0;
let pty = self.pty.borrow();
if let Some(data) = pty.miso.front() {
if pty.miso.front().is_some() {
if !self.notified_read {
self.notified_read = true;
Some(data.len())
} else {
None
events |= syscall::EVENT_READ;
}
} else {
self.notified_read = false;
None
}
}
fn fevent_writable(&mut self) -> bool {
let notified = self.notified_write;
self.notified_write = true;
!notified
if ! self.notified_write {
self.notified_write = true;
events |= syscall::EVENT_WRITE;
}
events
}
}