restructure Poll to hold a Table and fd instead of a RefMut<dyn WasiFile>
unfortunately, the borrow checker defeated me: changing the RwSubscription file form a Ref to a RefMut turned into borrow checker errors in the impl of the poll_oneoff trait method. This implementation makes an end run by having Poll hold onto the table and fd, and borrow the file at the site of use, rather than try to own the RefMut. I have no idea why this convinces the borrow checker that anything is different, but it does and I need to get this PR done and I don't think comprimising on this internal abstraction is worth fighting against
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use cap_std::time::Duration;
|
||||
use std::convert::TryInto;
|
||||
use std::future::{Future, Poll as FPoll};
|
||||
use std::future::Future;
|
||||
use std::ops::Deref;
|
||||
use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
@@ -23,15 +23,15 @@ pub async fn poll_oneoff<'a>(poll: &'_ Poll<'a>) -> Result<(), Error> {
|
||||
match s {
|
||||
Subscription::Read(f) => {
|
||||
futures.push(Box::pin(async move {
|
||||
f.file.readable().await?;
|
||||
f.complete(f.file.num_ready_bytes().await?, RwEventFlags::empty());
|
||||
f.file()?.readable().await?;
|
||||
f.complete(f.file()?.num_ready_bytes().await?, RwEventFlags::empty());
|
||||
Ok(())
|
||||
}));
|
||||
}
|
||||
|
||||
Subscription::Write(f) => {
|
||||
futures.push(Box::pin(async move {
|
||||
f.file.writable().await?;
|
||||
f.file()?.writable().await?;
|
||||
f.complete(0, RwEventFlags::empty());
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user