MCPcopy Create free account
hub / github.com/uiwjs/react-codemirror / Scheduler

Class Scheduler

core/src/timeoutLatch.ts:51–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51class Scheduler {
52 private interval: NodeJS.Timeout | null = null;
53 private latches = new Set<TimeoutLatch>();
54
55 add(latch: TimeoutLatch): void {
56 this.latches.add(latch);
57 this.start();
58 }
59
60 remove(latch: TimeoutLatch): void {
61 this.latches.delete(latch);
62 if (this.latches.size === 0) {
63 this.stop();
64 }
65 }
66
67 private start(): void {
68 if (this.interval === null) {
69 this.interval = setInterval(() => {
70 this.latches.forEach((latch) => {
71 latch.tick();
72 if (latch.isDone) {
73 this.remove(latch);
74 }
75 });
76 }, 1);
77 }
78 }
79
80 private stop(): void {
81 if (this.interval !== null) {
82 clearInterval(this.interval);
83 this.interval = null;
84 }
85 }
86}
87
88let globalScheduler: Scheduler | null = null;
89

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…