Just thought I’d share some details on some of the recent changes I’ve pushed to Qt 5 a few weeks ago. (Yes, this post is rather overdue, I’ve been a bit slack with writing it). If you were in Tampere when I gave a short, completely underprepared Q&A on Qt 5 a few days ago, this won’t be news to you, but I will go into a bit more detail.
On Linux, the (ancient, and no longer used by default) dnotify backend also met its maker. Since inotify has been around for some 6-7 years, it was about time, especially as the dnotify backend had some interesting bugs in behaviour.
The OS X FSEvents backend (also unused for quite some time, due to bugs, and not being a recommended way of working apparently) joined to make for a trinity of dead implementations. OS X’s watching is survived by kqueue, which it shares with BSD platforms.
The currently supported backends are:
- inotify (on Linux)
- kqueue (on BSD and OS X)
- WaitForMultipleObjects on Windows, which I need to become more familiar with. Not having a Windows machine has meant that I’m not really able to do much here…
Brad also took this work a step further: QFileSystemWatcher has never been documented as being thread-safe, but the engines may have happened to be more or less thread-safe thanks to living on a different thread to the QFileSystemWatcher, through mutexing. One part inside Qt itself actually needed this for autotests to function correctly, too: QFileSystemModel. He fixed this requirement, and was thus able to remove the mutexes from the engines. Thanks!
I’d also like to thank Brad, João Abecasis, and anyone I’ve forgotten for helping to review these changes and get them integrated.
(One thing I neglected to mention above – the thread story is a little more complicated on Windows. Windows still has threads inside the engine (although the engine itself is no longer a thread, so there’s still one less). This is necessary because WaitForMultipleObjects can only process up to MAXIMUM_WAIT_OBJECT handles at a time, unless you use multiple threads to do the monitoring, so that’s exactly what it does. It spawns multiple threads on-demand as soon as it can’t find a thread with a spare slot. But this is nothing new.)