!7 cmodule RegexpMatcher > DynPrintLogAndEnabled { transient L jobs = syncLinkedList(); transient ReliableSingleThread rst; // stats transient long jobsDone; transient Job shortestRegexp, longestRegexp; transient Job quickestJob, slowestJob; start { rst = dm_rst(r step); } sclass Job { S regexp, input; bool ignoreCase; O whenDone; // voidfunc(Matcher). called with null if error S moduleID; // for who are we doing this long executionTime; // after it ran void clean { whenDone = null; } } void step { Job job; while (licensed() && (job = syncPopFirst(jobs)) != null) pcall { long time = sysNow(); doJob(job); job.clean(); job.executionTime = elapsedMS(time); ++jobsDone; if (shortestRegexp == null || l(job.regexp) < l(shortestRegexp.regexp)) shortestRegexp = job; // if (job.executionTime } } void doJob(Job j) { if (!dm_moduleExists(j.moduleID)) ret; Matcher m = null; pcall { m = safeRegexpPossiblyIC(j.ignoreCase, j.regexp, j.input); } callF(j.whenDone, m); } // API void addJob(S moduleID, S regexp, S input, bool ignoreCase, O whenDone) q { jobs.add(nu Job(+moduleID, +regexp, +input, +ignoreCase, +whenDone)); //_change(); rst.trigger(); } void deleteJobsForModule(S moduleID) q { syncFilterLinkedListInPlace(jobs, job -> eq(job.moduleID, moduleID)); //_change(); } }