Closed blckngm closed 1 year ago
This type also will not have the problems described in #111.
@sopium Thank you, this looks awesome. I haven't taken a close look yet, but I will once #134 is closer to being merged (feel free to remind me, if I forget).
Once this is merged, do you think there's any reason to keep the original blocking API around?
cc @hawkw (I already pinged you on #134. I figured maybe you're interested in this one too.)
I tried to modify the Inotify
type to make it support both async and blockink API. I think it can work.
The trick is to use a fake PollEvented
wrapper when the async-await
feature is not enabled.
Interesting. What if we removed the async-await
feature and included that by default, would there be a reason to keep the blocking API? Not sure how the new futures and async/await work in detail, but I think I remember that the older futures hat a wait
method that could be used to block on a future. Maybe something like that could be used to completely replace the blocking API.
Not sure if that's the right approach. Just wondering.
Interesting. What if we removed the
async-await
feature and included that by default, would there be a reason to keep the blocking API? Not sure how the new futures and async/await work in detail, but I think I remember that the older futures hat await
method that could be used to block on a future. Maybe something like that could be used to completely replace the blocking API.Not sure if that's the right approach. Just wondering.
It should be possible: you can create a current_thread
runtime and block_on
the future.
But it's quite inefficient, a new runtime need to be created for every blocking read call.
And it means that tokio is always needed. Quite heavy a dependency when you only want to use blocking IO.
Sounds like it make sense to keep the traditional blocking API then. Thanks for the explanation!
This pull request is very old, and async/await support has been available in inotify-rs for a long time now. Closing.
(This includes changes from #134.)
This adds an async
Inotify
type. It has anasync fn read_events
(close #121):that is basically the same as the original
read_events
function, but awaits on theread
:This addresses the efficiency concern in #112: no additional allocation is required.