MCPcopy Create free account
hub / github.com/Effect-TS/effect / scheduleTask

Method scheduleTask

packages/effect/src/Scheduler.ts:108–124  ·  view source on GitHub ↗
(task: () => void, priority: number)

Source from the content-addressed store, hash-verified

106 buckets: Array<[priority: number, tasks: Array<() => void>]> = []
107
108 scheduleTask(task: () => void, priority: number): void {
109 const buckets = this.buckets
110 const len = buckets.length
111 let bucket: [number, Array<() => void>] | undefined
112 let index = 0
113 for (; index < len; index++) {
114 if (buckets[index][0] > priority) break
115 bucket = buckets[index]
116 }
117 if (bucket && bucket[0] === priority) {
118 bucket[1].push(task)
119 } else if (index === len) {
120 buckets.push([priority, [task]])
121 } else {
122 buckets.splice(index, 0, [priority, [task]])
123 }
124 }
125
126 drain() {
127 const buckets = this.buckets

Callers

nothing calls this directly

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected