louiscad
11/15/2019, 3:47 PM<http://Dispatchers.IO|Dispatchers.IO>
and using readText()
or readBytes()
, but this still blocks a thread while we are waiting for storage and not the CPU.diesieben07
11/15/2019, 3:51 PMAsynchronousFileChannel
, which is callback based and could be adapted to suspend
functions.Paul Woitaschek
11/15/2019, 4:01 PMoctylFractal
11/15/2019, 4:04 PMselect
, but in Java async io simply runs select
forever in a jvm-managed threadLuis Munoz
11/15/2019, 4:14 PMoctylFractal
11/15/2019, 5:47 PMAsynchronousFileChannel
StevieB
11/15/2019, 6:58 PMlouiscad
11/15/2019, 8:48 PMelizarov
11/15/2019, 9:42 PMelizarov
11/15/2019, 9:42 PMlouiscad
11/15/2019, 11:59 PM<http://Dispatchers.IO|Dispatchers.IO> { file.readText() }
?StevieB
11/16/2019, 12:45 AMelizarov
11/16/2019, 7:48 AMAsynchronousFileChannel
does inside is not different from <http://Dispatchers.IO|Dispatchers.IO> { file.readText() }
, but with much more overhead and much less convenenient API on top of that.uli
11/16/2019, 2:21 PMuli
11/16/2019, 2:29 PMRegular files are always readable and they are also always writeable. This is clearly stated in the relevant POSIX specifications. I cannot stress this enough. Putting a regular file in non-blocking has ABSOLUTELY no effects other than changing one bit in the file flags.
elizarov
11/16/2019, 4:02 PMelizarov
11/16/2019, 4:03 PMLinux being the exception, its posix AIO implementation in glibc emulates async operations with user level threads, whereas its native async I/O interface (io_submit() etc.) are truly asynchronous all the way down to the driver, assuming the driver supports it.
louiscad
11/16/2019, 6:31 PMelizarov
11/16/2019, 7:04 PMlouiscad
11/17/2019, 1:56 PMelizarov
11/17/2019, 2:48 PMgergo
11/18/2019, 9:03 AMelizarov
11/18/2019, 9:08 AMensureActive
between blocks to support cancellation.gergo
11/18/2019, 9:09 AMelizarov
11/18/2019, 9:09 AMlouiscad
11/18/2019, 9:27 AMView.java
from Android, ~30K lines of code), the best thing to do would be to use bufferedReader()
, reading chunk by chunk and calling ensureActive()
before reading each chunk?elizarov
11/18/2019, 9:28 AMlouiscad
11/18/2019, 9:30 AMelizarov
11/18/2019, 9:34 AM