+ + FileEvent.runWhenDeliveryOver(Runnable) method added to support + easier processing of batch sets of events. +
+FileEvent
. The FileObject
where the action occurred
* is assumed to be the same as the source object.
@@ -135,6 +137,33 @@
return expected;
}
+ /** Support for batch processing of events. In some situations
+ * you may want to delay processing of received events until the last
+ * known one is delivered. For example if there is a lot of operations
+ * done inside {@link FileUtil#runAtomicAction(java.lang.Runnable)}
+ * action, there can be valid reason to do the processing only after
+ * all of them are delivered. In such situation attach your {@link Runnable}
+ * to provided event. Such {@link Runnable} is then guaranteed to be called once.
+ * Either immediatelly (if there is no batch delivery in progress)
+ * or some time later (if there is a batch delivery). You can attach
+ * single runnable multiple times, even to different events in the
+ * same batch section and its {@link Runnable#run()} method will still be
+ * called just once. {@link Object#equals(java.lang.Object)} is used
+ * to check equality of two {@link Runnable}s.
+ *
+ * @since 7.24
+ * @param r the runnable execute when batch event deliver is over
+ * (can be even executed immediatelly)
+ */
+ public final void runWhenDeliveryOver(Runnable r) {
+ Collection