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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top