WatchService questions
Alan Bateman
Alan.Bateman at Sun.COM
Wed Jan 6 03:51:52 PST 2010
Sebastian Sickelmann wrote:
> :
> So a user of the WatchService-API cannot count in the order of the events.
The sequence of events needs to keep the user's view of the directory
consistent. This implies an ordering for at least the create and delete
events (irrespective of implementation). Your mails do raise the
question on if modification events need to be ordered. Clearly there are
cases where they should be ordered with respect to other event kinds. If
a file is modified after it is created then you should expect the
modification event after the create event. There are other examples like
this. If several files are modified at around the same time then the
ordering may or may not be useful but clearly cannot be guaranteed
everywhere. Where it is important then the user can examine the file's
modification time if that helps. So I think you have a worthy point and
we should think about this case further to see if we should change the
implementation. If it is changed then there are several possible
approaches - for example modification events could be merged towards the
head if the pending list reaches its limit. Alternatively modification
events could initially be stored in a map (for fast lookup) and only
added to the pending list when an event of a different kind needs to be
queued (or the user retrieves the pending events).
-Alan.
More information about the nio-dev
mailing list