Git Product home page Git Product logo

tokio-linux-aio's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar fallingsnow avatar gitter-badger avatar hmwill avatar kevin-vigor avatar srijs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tokio-linux-aio's Issues

Switch maintenance of this crate

Hi,

Thanks for the great work on this crate. However, it's not much maintained and outdated at the time. I have mostly finished the huge refactoringwith support for tokio 0.2, and async/await, and with a few improvements on performance and stability. I'd like to continue maintaining it, and wondering, if it would be possible to pass the ownership of the tokio-linux-aio crate to me?

Add support for completely non-blocking I/O submission

Even though meant to be non-blocking. io_submit can block in some cases. io_submit supports a flag RWF_NOWAIT that can be used to require the call to be non-blocking. Specifically, this option means:
Don't wait if the I/O will block for operations such as file block allocations, dirty page flush, mutex locks, or a congested block device inside the kernel.

When RMF_NOWAIT is set, I/O requests may fail immediately with EAGAIN.

This issue is about investigating if RWF_NOWAIT can be meaningfully integrated into this API.

Return how many bytes read/write from io_getevents

Linux's libaio put how many bytes read/write in io_event.res using a positive integer.
I did not find the document, but the kernel code proves that ╮( ̄▽ ̄)╭

https://github.com/torvalds/linux/blob/3717f613f48df0222311f974cf8a06c8a6c97bae/fs/aio.c#L1535-L1541

usually, it is the device block size, but actually, it is equal with the blocking system call read(2).

The simplest way is change fn retrieve_result(&mut self) -> Result<futures::Async<()>, io::Error> to fn retrieve_result(&mut self) -> Result<futures::Async<u64>, io::Error>

It will be a lot of broken change.

diff --git a/src/lib.rs b/src/lib.rs
index 537f6d8..0751418 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -207,7 +207,7 @@ impl AioBaseFuture {
 
     // Attempt to retrieve the result of a previously submitted I/O request; this may need to
     // wait until the I/O operation has been completed
-    fn retrieve_result(&mut self) -> Result<futures::Async<()>, io::Error> {
+    fn retrieve_result(&mut self) -> Result<futures::Async<u64>, io::Error> {
         // Check if we have received a notification indicating completion of the I/O request
         let result_code = match self.state.as_mut().unwrap().completed_receiver.poll() {
             Err(err) => return Err(io::Error::new(io::ErrorKind::Other, err)),
@@ -229,17 +229,17 @@ impl AioBaseFuture {
         if result_code < 0 {
             Err(io::Error::from_raw_os_error(result_code as i32))
         } else {
-            Ok(futures::Async::Ready(()))
+            Ok(futures::Async::Ready(result_code as u64))
         }
     }
 }
 
 // Common future base type for all asynchronous operations supperted by this API
 impl futures::Future for AioBaseFuture {
-    type Item = ();
+    type Item = u64;
     type Error = io::Error;
 
-    fn poll(&mut self) -> Result<futures::Async<()>, io::Error> {
+    fn poll(&mut self) -> Result<futures::Async<u64>, io::Error> {
         let result = self.submit_request();
 
         match result {
@@ -298,13 +298,13 @@ impl<ReadWriteHandle> futures::Future for AioReadResultFuture<ReadWriteHandle>
 where
     ReadWriteHandle: convert::AsMut<[u8]>,
 {
-    type Item = ReadWriteHandle;
+    type Item = (ReadWriteHandle, u64);
     type Error = AioError<ReadWriteHandle>;
 
     fn poll(&mut self) -> Result<futures::Async<Self::Item>, Self::Error> {
         self.base
             .poll()
-            .map(|val| val.map(|_| self.buffer.take().unwrap()))
+            .map(|val| val.map(|nbytes| (self.buffer.take().unwrap(), nbytes)))
             .map_err(|err| AioError {
                 buffer: self.buffer.take().unwrap(),
                 error: err,
@@ -329,13 +329,13 @@ impl<ReadOnlyHandle> futures::Future for AioWriteResultFuture<ReadOnlyHandle>
 where
     ReadOnlyHandle: convert::AsRef<[u8]>,
 {
-    type Item = ReadOnlyHandle;
+    type Item = (ReadOnlyHandle, u64);
     type Error = AioError<ReadOnlyHandle>;
 
     fn poll(&mut self) -> Result<futures::Async<Self::Item>, Self::Error> {
         self.base
             .poll()
-            .map(|val| val.map(|_| self.buffer.take().unwrap()))
+            .map(|val| val.map(|nbytes| (self.buffer.take().unwrap(), nbytes)))
             .map_err(|err| AioError {
                 buffer: self.buffer.take().unwrap(),
                 error: err,
@@ -353,7 +353,7 @@ pub struct AioSyncResultFuture
 
 impl futures::Future for AioSyncResultFuture
 {
-    type Item = ();
+    type Item = u64;
     type Error = io::Error;
 
     fn poll(&mut self) -> Result<futures::Async<Self::Item>, Self::Error> {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.