Description
Hey there,
I'm experimenting with iui as a new Rust programmer and I'm unsure whether I've hit upon a design issue with UI::queue_main
, or if there's a solution I've just missed, as this method isn't used in any of the examples.
According to the iui documentation, UI::queue_main
will queue a function to execute on the GUI thread - I assume this is the thread that called UI::init()
.
libui explicitly states you can call uiQueueMain
from any thread, but I can't figure out how to do this with iui; it requires a UI
instance which I cannot obtain in non-GUI threads as UI
is neither Send nor Sync.
Is there a way to do this, or is this a bug/design flaw? Any advice would be appreciated!
For reference - I'm trying to offload ongoing USB device I/O using hidapi-rs onto a background thread and have it notify the GUI thread when data comes in or when the device is connected/disconnected.
The only method I can figure out for doing this is to have the GUI create a channel where the Sender
is moved into the background thread and Reciever::try_recv
is called regularly on a timer, but this feels inelegant to me and I'd much rather be able to have the background thread notify the GUI through libui's queuing mechanism so that it can update immediately.