Created
October 10, 2011 03:25
-
-
Save hamrickdavid/1274571 to your computer and use it in GitHub Desktop.
GCD for monitoring filesystem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int fildes = open("/path/to/config.plist", O_RDONLY); | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE,fildes, | |
DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND | DISPATCH_VNODE_ATTRIB | DISPATCH_VNODE_LINK | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, | |
queue); | |
dispatch_source_set_event_handler(source, ^ | |
{ | |
//Reload the config file | |
}); | |
dispatch_source_set_cancel_handler(source, ^ | |
{ | |
//Handle the cancel | |
}); | |
dispatch_resume(source); | |
... | |
// sometime later | |
dispatch_source_cancel(source); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment