sclass ManualTailFile extends TailFile { long lastCheck; Lock lock = lock(); // onData: Runnable or voidfunc(S) *(final File *file, int *interval, fO *onData) {} *(final File *file, fO *onData) { interval = 100; } // updates in this thread void check() { long l2 = 0; { lock lock; long now = sysNow(); if (now < lastCheck+interval) ret; lastCheck = now; l2 = l(file); if (l2 < l) l = 0; // file shrunk (log rotated!) - start over from beginning of file if (l2 == l) hasIdled = true; else pcall { if (debug) print("New data in " + f2s(file) + ": " + n2(l2-l, "byte")); } } // call onData outside of locked part for (S s : loadTextFilePart_iterator(file, l, l2)) pcallF(onData, s); l = l2; } }