IONotificationPortGetRunLoopSource isn't as generic as you might think
Of IONotificationPortGetRunLoopSource, its header says only: "Returns a CFRunLoopSource to be used to listen for notifications." You might think from this generic description that the function would be useful for listening to any old notification. However, it calls CFMachPortCreateWithPort, passing an internal callback function which works well if the only notifications you care about are the ones you can create with high-level functions such as IOServiceAddMatchingNotification. If you want to field any other notification, you're out of luck, because that internal callback function will most likely ignore or misinterpret the 'type' field of your message header. So, rather than IONotificationPortGetRunLoopSource, call CFMachPortCreateWithPort and CFMachPortCreateRunLoopSource.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment