Async/Await - The challenges besides syntax - Cancellation

Is there no easy way for any IO queuing function to require that the buffer live as long as the uring/executor? Like

struct Executor<'a> { futures: Vec<SomeFutType<'a>> }
impl <'a> Executor<'a> { fn queue_read(&self, buf: &'a mut [u8]) }

If this is possible, I would imagine patterns like this would be allowed

executor.spawn(async || {
     let mut buf = [0u8; 1024]
     fd.queue_read(&mut buf).await;

});

but not this:

executor.spawn(async || {
  let queued = { 
        let mut buf = [0u8; 1024];
        fd.queue_read(&mut buf)
  };
  queued.await;
});   

Has anyone experimented with this? In that case it’d only live as long as the “task” or top level future or whatever, but not allow anything to live shorter than that.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.