-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add a non-blocking alternative to wait_for_action #36
Comments
Hi there! |
Some of the actual use cases I either want to port from Python or implement in Rust from the start if it's not too bothersome include:
|
I was thinking more along the line of code examples. But I assume you imagine an api like this: let notification_future = Notification::new()
.summary("you got mail")
.action("clicked", "open Mutt") // IDENTIFIER, LABEL
.show()
.unwrap()
.then({|action|
match action {
"clicked" => {unimplemeted!()},
"__closed" => println!("the notification was closed"),
_ => ()
}
}); which would not block. You would still have to have your own event loop though. |
I was envisioning something broadly like what you propose, combined with some "Handle if this is ours. Otherwise, ignore. Indicate whether it was ours." function that the event loop would call upon receipt of a D-Bus message. (Possibly after ruling out its D-Bus events of its own.) I'm not very experienced with Rust, compared to GCed languages, so I don't trust myself to design a good API and I'm flexible on what it should look like. |
what do you mean with ours? ATM you could have the blocking api in a thread, thats not that expensive. I can add an optional feature that does what I described here, but it would add a dependency to the futures library for me and the user. Other than e.g. javascript rust doesn't have a runtime with an event loop. |
Threads are best suited to working in parallel, not waiting in parallel. As a matter of principle, I try to avoid using them for the latter. Also, it's bad enough when I have to open more than one X11 socket from the same process (eg. in Python programs where I need
I missed the I didn't mean to ask for futures. All I want is an API which makes it comfortable to call something like As-is, I'd have to copy-paste an unappealing amount of code from notify-rust to my "We received a D-Bus message" handler. |
Oh, as for this...
in that context, "ours" refers to notify-rust. Here it is rephrased:
|
Do you mean something like this internal function? we could put the body of this loop in an extra function and make that public. |
That sounds like it's probably the right approach, but I'm overdue for bed and tiredness has hit me like a ton of bricks, so I'll give you a proper reply after I've slept and can think again. |
Sorry about going silent for a couple of days. I woke up to find myself swamped with more pressing concerns that I'm still working to clear out. I'll leave this tab open and get back to you as soon as I can find a little more time. |
There is no need to apologise or rush at all. Same here |
Still, I said "I'll give you a proper reply after I've slept and can think again," which generally implies that one intends to reply in some way the following day. |
From what I could gather by looking at the API docs, the only current alternative to
wait_for_action
is to reinvent the whole thing as part of another event loop, even if all the user wants to do is listen for a few extra D-Bus signals.It'd really help if
wait_for_action
were refactored so that it's not necessary to copy-and-paste the relevant bits into dependent projects which want to run more general event loops.The text was updated successfully, but these errors were encountered: