Beagle's internal inotify interface change

I've just committed a change to beagle's inotify interface, which affects how
you request certain files to be watched by inotify and how you link in a
function to be notified on inotify event.

The new interface means that you basically 'subscribe' and 'unsubscribe' to
and from inotify events that you are interested in. All existing inotify users
have been converted.

New API example:

public static void WatchStuff ()
	Inotify.Watch mywatch = Inotify.Subscribe ("/home/dsd", MyCallback,
		Inotify.EventType.Create | Inotify.EventType.Modify);

private void MyCallback (Inotify.Watch watch, string path, string subitem,
			string srcpath, Inotify.EventType type)
	Console.WriteLine ("I got event {0} on {1}!", type, subitem);


- With the old API, you had to request a watch on a specific file or
directory, *and* add a 'callback' function to the core inotify event.
If two or more users created an inotify watch on the same file/directory, you
ran into brokenness, which was one of the reasons why this system was
introduced. With the new API, you just call Inotify.Subscribe() and the job is
done (no need to tag onto any event, you subscribe with a callback method).

- The concept of getting an integer watch description (wd) has been
abstracted. When you request a watch, you get an Inotify.Watch object in return.

- If you didn't keep it around, the same Inotify.Watch object gets included in
the callback (first parameter).

- To unsubscribe, you can call the Unsubscribe() method on your Inotify.Watch
object. When you have unsubscribed, your callback is guaranteed not to be
invoked for that particular subscription, unless you were to subscribe again.

- Previously, any callback methods you wrote would be called on each and every
inotify event, so the first thing you'd do is say "am I interested in this
event?" before doing any real work. This often involved having to store the
'wd' of the watch, or even worse, a hashtable of wd's. Now that the
subscription system is in place, you don't have to worry about this; you are
guaranteed only to be called for events on the files/directories that you
subscribed to, and only for events of the specific type(s) that you subscribed to.

- It's worth pointing out that multiple subscriptions can share the same
callback (e.g. FileSystemQueryable does this).

I think that's everything.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]