Closed flxo closed 2 years ago
Thanks for raising @flxo.
This makes sense to me. wdyt @lifupan / @Tim-Zhang ?
Hi @flxo @jodh-intel
Yeah,It's reasonable to add an async version of oom event watcher and use a feature to control it. The PR is welcomed, thanks.
Thanks for your feedback! I pushed #53 and will continue with some tests in my environment.
Closing due to #53
Is your feature request related to a problem? Please describe.
The functions
events::notify_on_oom_v1
andevents::notify_on_oom_v2
return astd::sync::mpsc::Receiver
. Using the std channels in a tokio environment is cumbersome because it requires to spawn a thread that blocks onReceiver::recv
. There's an additional thread spawned inside those functions that block on reading the eventfd and sending the notification via the channel.Describe the solution you'd like
Add a feature
tokio
that returns aResult<tokio::sync::mpsc::Receiver>
or aResult<impl Stream<Item = Stream>>>
that seamlessly integrates into tokio applications. For the implementation the tokio eventfd can be used that uses a non blockingevent_fd
.Additional context
The dependency list of
cgroups-rs
is very small which is nice. Addingtokio
as a dependency must definitely be hidden behind a feature.I can come up with a proposal PR if wanted. :-)