4 ms·
Photon, 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 t
by Animats 11y ago
Photon, 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 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.
- Arnt 11y agoI don't remember discussing either of those while writing Qt. Rather, single-threading followed from two big points. First, the user calls the program rather than the other way around, and the user isn't multithreaded. Second, there aren't performance problems with the UI, and certainly none that require fighting #1. Some programs need more than one thread. But that need does not originate within the UI, and complicating the UI for it would comply with RFC 1925 point 5.
- damienkatz 11y agoRust prevents races but not deadlocks, which is one of the bigger problems in multithreaded GUI code.
- sillysaurus3 11y agoLocks 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 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!
- jpgvm 11y agoOne can probably argue it's not even more complex at all. Locks just look simple because it's "just chuck a mutex around it", in reality though it's all a mirage. Locks are comfortable, not simple - is how I like to put it at least.
- 885895 11y agoI would like to read more about what you described here. Know of any good articles or open source projects where this is done?
- fmstephe 11y agoIf you like Go I have written a ringbuffer library here https://github.com/fmstephe/flib https://github.com/fmstephe/flib have a look in queues/spscq. spsc here stands for single producer, single consumer. I gave a talk in London about these queues here https://skillsmatter.com/skillscasts/6163-high-performance-single-producer-single-consumer-in-memory-queue https://skillsmatter.com/skillscasts/6163-high-performance-s... ------------------- But all of this work is based on the work, and teaching, of Martin Thomson. Martin Thomson has published a large collection of data structures (which probably include these ringbuffers (I haven't checked specifically)) https://github.com/real-logic/Agrona https://github.com/real-logic/Agrona If you are near Ireland I highly recommend Martin Thomson's concurrency course http://instil.co/courses/writing-concurrent-code-with-lock-free-algorithms/ http://instil.co/courses/writing-concurrent-code-with-lock-f... ---------- I highly recommend Nitsan Wakart's blog. He covers a lot of interesting ground, all in Java. Probably best to start at the early blog posts and work your way forward. http://psy-lob-saw.blogspot.co.uk/ http://psy-lob-saw.blogspot.co.uk/ Nitsan contributes to a very focused java library here https://github.com/JCTools/JCTools https://github.com/JCTools/JCTools
- ryanjshaw 11y agoWhy: https://github.com/LMAX-Exchange/disruptor/wiki/Blogs-And-Articles https://github.com/LMAX-Exchange/disruptor/wiki/Blogs-And-Ar... Java: https://lmax-exchange.github.io/disruptor/ https://lmax-exchange.github.io/disruptor/ .NET: https://github.com/disruptor-net/Disruptor-net https://github.com/disruptor-net/Disruptor-net