-
Notifications
You must be signed in to change notification settings - Fork 85
Ability to remove handlers, and ability to add FnOnce
handlers instead of FnMut
.
#130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@Detegr I have noted, that its been a while, since maintainers interacted in Issues or PRs. I would ask for you, or one of other maintainers (if any) to take a look at the latest PRs. I am pinging you here just in case the issue being here is not getting notifications. Best regards. |
Hi. Yes, this is unfortunately the case. This project is one of the classic cases where a hobby library suddenly gets a lot of users and I, being a full time empolyee and a father of two kids, don't really have the time and the interest required to keep up with it. I have also intentionally rejected adding more complexity to the crate because I feel responsible for keeping it clean for possible unsafety and/or crashes. That being said, I'll try to go through the PRs this friday where I should have some free time. No promises. |
Thanks for the contribution. I skimmed through the code and generally it looks good. This use case however isn't worth adding 300+ lines of new code in my opinion. I would rather just implement the function that allows setting the handler back to a default one (see #106 for context). |
Basically, To be fair:
The rest are the:
|
Right, I missed the actual platform implementations the first time skimming through the code. Can you explain me how this approach is better than exposing the |
Is is already exposed via: That function is a safe wrapper that calls platform-defined
You could already do that with regular |
Changes:
set_handler_once()
,try_set_handler_once()
that acceptFnOnce() -> T
instead of FnMut. Those variants return whateverFnOnce
returns via thread handle.JoinHandle<_>
in order to be able to track threads, and get values fromFnOnce
.remove_all_handlers()
. It deinitializes the OS signal handler and stops all awaiting ctrl+c handlers.FnOnce
, after running once, automatically callsremove_all_handlers()
.Also, added a test
tests/main/deinit.rs
that shows and tests this behaviour.Reasons, why I propose to add this:
tokio::sync::oneshot::Channel
just once.Even if this PR will not be approved - I would like to get some feedback.