Closed linrongbin16 closed 1 year ago
Or the very inside callback uv.fs_close
in uv.fs_read
will block all the callback chain ?
And 1 more question, since I want to write something lower the latency of reading file, I'm thinking that I should use offset
and size
to read block by block (for example every block 4096 bytes). Since there're so many callbacks, I think I can use lua coroutine
to yield to a consumer function to consume the readed data, and this fs_read
is a producer function to produce data.
I have tried the async sample in doc: https://github.com/luvit/luv/blob/master/docs.md#file-system-operations, but it looks like it's not going to wait until the fs_read complete, so now I'm using the sync fs_read with a batchsize=4096
to batch read the file.
Hi, I'm reading the file operation in the doc: https://github.com/luvit/luv/blob/master/docs.md#file-system-operations, I feel like I understand the sync and async operation.
While I want to make sure about one thing, in async
fs_read
, usually we registered a callback function, which is called when the file read operating is done.But when
fs_read
is doing the job in another thread (I'm not quite sure if this is the correct words to describe it, I just mean that whilefs_read
is reading the file, I can still do something in the main thread), what should I do to wait thefs_read
until it's done? use theuv.run()
API just like when I use theuv.spawn()
?