FSEventStream advice

  • I've traced the source of my memory corruption (cf) to a piece of 3rd party code that monitors for directory changes using kqueue(). This hasn't given any trouble for years, but now I'm making a lot of hardworking threads the bug is making itself known.

    I'm going to see if it's something obvious, but given how subtle and difficult this one has proved to be to track down (doesn't show up when running with the debugger), I'm also considering replacing it with something new based on FSEvents.

    The only small issue I see with that right now is that you have to specify the list of directories "up front" and there isn't a way to change them while the FSEvent stream is running. As the user uses my app, the directories to be monitored will need to change, so I'm wondering what best practice is:

    a). stop the stream and schedule a new one with the new list of paths,
    b). create a separate stream for each directory I'm interested in.

    I'm guessing that a) would be more efficient, but b) is going to be more convenient.

    Any advice?

    --Graham
  • On 2012 Jun 03, at 16:13, Graham Cox wrote:

    > I'm going to see if it's something obvious, but given how subtle and difficult this one has proved to be to track down (doesn't show up when running with the debugger), I'm also considering replacing [kqueue] with something new based on FSEvents.

    FSEvents should be used to watch a directory.  kqueue() should be used to watch a regular file.

    > As the user uses my app, the directories to be monitored will need to change, so I'm wondering what best practice is:
    >
    > a). stop the stream and schedule a new one with the new list of paths,
    > b). create a separate stream for each directory I'm interested in.
    >
    > I'm guessing that a) would be more efficient, but b) is going to be more convenient.
    >
    > Any advice?

    Probably doesn't matter unless the number of streams is going to be more than a few, then you'd want (a).
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today