Skip to content
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

Using ThreadPool :interactive for the Gtk loop #47

Closed
nHackel opened this issue Dec 8, 2023 · 2 comments
Closed

Using ThreadPool :interactive for the Gtk loop #47

nHackel opened this issue Dec 8, 2023 · 2 comments

Comments

@nHackel
Copy link
Contributor

nHackel commented Dec 8, 2023

Hello! I've been wondering if there have been any attempts to get the GTK loop running in a task scheduled on the interactive pool if available.

A while ago I made a quick attempt at just scheduling the glib_main in the interactive pool but things crashed. I'd be willing to try again with some pointers

@jwahlstrand
Copy link
Member

jwahlstrand commented Dec 9, 2023

I did look into this a bit and (at least in 1.9) the GTK loop runs in the interactive pool, if it exists, without any extra setup.

This code, whether run in the REPL or as a script, for me prints "interactive" when there's an interactive thread pool. The @idle_add macro calls a function from the main loop so it's an easy way to check this.

using Gtk4

@idle_add println(Threads.threadpool())
if !isinteractive()
    Gtk4.GLib.start_main_loop()
    sleep(0.1) # allow println to be called before the loop is stopped
end

I just added a few examples that use threads to do work, and (at least for me, on Linux) things work well whether I start Julia with an interactive threadpool or not.

@nHackel
Copy link
Contributor Author

nHackel commented Dec 11, 2023

Ah, very cool! I just tried it out and yes it just works 😄

The context is that previously we had a very IO intensive task running along our GUI and the GTK loop halved our data transmission rates. Now with just adding the thread pool we are back to the expected rate!

@nHackel nHackel closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants