On 01/13/2015 03:54 PM, Luciano Ramalho wrote: > Reviving the thread... if I understand correctly, there is no portable > way to do disk I/O asynchronously (and the gist [1] provided by the OP > is bogus: the read_data function will block the event loop). Is my > understanding correct? > > [1] https://gist.github.com/kunev/f83146d407c81a2d64a6 > <https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2Fkunev%2Ff83146d407c81a2d64a6&sa=D&sntz=1&usg=AFQjCNG-U5Mxoo48n49VafkFEr4TnQVm8g> >
Yes, that will block the event loop. > Second question: Node.js does have a complete async API for doing > filesysem I/O, even an async stat function! But after reading Glyph's > Q&A on Stackoverflow I conclude those filesystem I/O functions in Node > must rely on threads underneath, since we can't rely on OS APIs for > async filesystem I/O. Is that it? > libuv (Node's platform layer) core dev here. That's right all filesystem operations are run in a threadpool, much like asyncio runs getaddrinfo in a ThreadPoolExecutor. Here is an interesting read: http://blog.libtorrent.org/2012/10/asynchronous-disk-io/ Cheers, -- Saúl Ibarra Corretgé bettercallsaghul.com
signature.asc
Description: OpenPGP digital signature
