[Development] Should QFileSystemWatcher be thread-safe? (Qt 5.8.0)

Thiago Macieira thiago.macieira at intel.com
Sat Sep 30 00:31:36 CEST 2017


On sexta-feira, 29 de setembro de 2017 14:47:29 PDT René J. V. Bertin wrote:
> Thiago Macieira wrote:
> >> How does QFSW handle a situation in which an already watched directory is
> >> changed while another directory is being added? Would something else
> >> happen
> >> when adding directories happens on a background thread while change
> >> signals
> >> are connected to slots on the main thread?
> > 
> > The Darwin implementation has an internal mutex so that the dispatcher
> > thread (I'm assuming) is able to get to the current state.
> 
> Can I assume that the other platforms have a similar feature that blocks
> access to the current state while entries are being added or removed (and
> also defers adding/removing entries while sending out change
> notifications)?

You cannot, because neither the kqueue, inotify or poll backends do that. 
Those three have no mutexes at all. You have to block the event loop of the 
thread they were created on.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list