2

I'm writing an application in C++ using Qt on Mac. I want to detect drives being mounted and unmounted so I am using the DiskArbitration framework. I registered some callback functions via DARegisterDiskAppearedCallback and DARegisterDiskDisappearedCallback but these only fire when there is a runloop.

What is the best way to start a suitable runloop ?

QThread with CFRunLoopRun (sounds a bit excessive) ?

Please give details, I am not well versed in threads.

koan
  • 3,596
  • 2
  • 25
  • 35
  • Is it even possible to do `CFRunLoopRun` from `QThread`? I want to use it for some library that does not have a specialized method like `DASessionSetDispatchQueue`. – dashesy Sep 22 '15 at 01:34

1 Answers1

2

On OS X 10.7+ you can use DASessionSetDispatchQueue to have your callbacks invoked on a dispatch queue of your choosing. You could then forward the data from the callback over to your regular Qt event loop.

bdash
  • 18,110
  • 1
  • 59
  • 91