Closed mitchhentges closed 6 years ago
Oh, and I needed to base this off of #5 so that it would build locally. If this PR should be merged, it should happen after #5
Are you sure they are thread safe though? As far as I know GDI+ is not thread safe (I'm not sure if libui uses that though), so just putting impl Send there without verifying if the OS APIs are thread safe seems bad.
Hmm, I'm not 100% sure that it's thread safe, but it's a start. Right now, it's impossible to manipulate controls from other threads. Now, it appears to work with a dummy progress bar app: https://github.com/mitchhentges/libui-rs/blob/ecm-example/ui/examples/ecm-download.rs#L54
Maybe it's just thread safe if you use queue_main? I'm not sure.
So, if anything, I was hoping that this would start discussion on designing a safe way to use libui in a multithreaded environment.
This will allow controls to be cloned and reused from other threads. I'm not sure how to make this Rust-y, though, because perhaps each
Control
needs some more guarantees before it canimpl Send
.Either way, it's working for me locally, so maybe it's useful for all