sclass TailFile { int interval; long l; new Flag stopped; java.util.Timer timer; ReliableSingleThread thread; volatile bool hasIdled; *(final File file, int *interval, fO onData) { thread = new ReliableSingleThread(r { long l2 = l(file); if (l2 < l) l = 0; if (l2 == l) hasIdled = true; else pcall { S text = null; pcall { // TODO: load in parts text = loadTextFilePart(file, l, l2); } if (nempty(text)) pcallF(onData, text); l = l2; } }); } void start { timer = doEvery(interval, r { if (!stopped.isUp()) thread.trigger() }); } void stop { timer.cancel(); timer = null; if (stopped.raise()) thread.triggerAndWait(); // One last time baby } bool started() { ret timer != null; } }