Multithreaded toolkits: A failed dream? (2004)
weblogs.java.net
Multithreaded toolkits: A failed dream? (2004)
1–10 of 64 posts
Re: Multithreaded toolkits: A failed dream? (2004)
#2It's going to be interesting to see what happens when someone implements a new GUI in Rust. The classic problem with GUIs has been that ownership management for both allocation and locking was a big problem. Rust's borrow checker can help a lot with the bookkeeping needed to get that right.
Re: Multithreaded toolkits: A failed dream? (2004)
#3Re: Multithreaded toolkits: A failed dream? (2004)
#4Photon, the old GUI for QNX, supports some degree of multithreading. You can update the values of various display elements such as meters, progress bars, and text displays from other threads. That GUI is often used for control panels, with real-time data coming in that needs to be current on the display, which is why they made that work. It's going to be interesting to see what happens when someone implements a new G…
Re: Multithreaded toolkits: A failed dream? (2004)
#5Photon, the old GUI for QNX, supports some degree of multithreading. You can update the values of various display elements such as meters, progress bars, and text displays from other threads. That GUI is often used for control panels, with real-time data coming in that needs to be current on the display, which is why they made that work. It's going to be interesting to see what happens when someone implements a new G…
Rust prevents races but not deadlocks, which is one of the bigger problems in multithreaded GUI code.
It's possible to manage a ringbuffer without any locks. The trick is to have a counter for the producer thread, and a counter for each consumer thread. Whenever the producer wants to know "Is it safe to add a message?" it takes the minimum of all consumer counters, modulo the size of the ringbuffer. The result is the smallest index that the producer must not write beyond.
In other words, you always know when you're producing messages too quickly and need to wait on the consumers. And the consumers know when there's a message waiting -- they just look at the producer's counter. Blazingly fast, and no locks. Cool trick!
Re: Multithreaded toolkits: A failed dream? (2004)
#6Earlier quoted context omitted.
Rust prevents races but not deadlocks, which is one of the bigger problems in multithreaded GUI code.
Locks turn out to be unnecessary for multithreaded code. A ringbuffer of messages is only slightly more complex, yet the gains are massive. Both in performance and simplicity. It's possible to manage a ringbuffer without any locks. The trick is to have a counter for the producer thread, and a counter for each consumer thread. Whenever the producer wants to know "Is it safe to add a message?" it takes the minimum of a…
Re: Multithreaded toolkits: A failed dream? (2004)
#7Handling OpenGL context access from multiple threads is terrible, too. I'm quite excited about the additional threading niceties that we're getting in Vulkan, which should allow separate threads to re-render parts of the UI and then send the command buffers back to the main thread.
Re: Multithreaded toolkits: A failed dream? (2004)
#8Re: Multithreaded toolkits: A failed dream? (2004)
#9What about functional reactive programming? And what about flux pattern? Didn't these resolve this "failed dream" of multi-threaded GUI update? (I am asking real, not rhetorical, questions.)
The discussion is about the 'dream' of pushing a button from a worker thread.
Re: Multithreaded toolkits: A failed dream? (2004)
#10User interaction proceeds sequentially, so most objects don't require locks. The rare exceptions in my software is rendering or IO on a separate thread, and these don't nicely fit abstraction models, as mentioned in other posts they involve C-style state machines like OGL.
A multi-threaded GUI seems like a great way to kill performance, with little advantage.