MCPcopy Create free account
hub / github.com/ShouChenICU/FastSend / EventQueue

Class EventQueue

app/utils/PeerDataChannel.ts:246–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246export class EventQueue<T> {
247 private tail: Promise<void> = Promise.resolve()
248 private handler: (e: T) => Promise<void>
249
250 constructor(handler: (e: T) => Promise<void>) {
251 this.handler = handler
252 }
253
254 public enqueue(e: T): void {
255 // 每次把新任务链到上一个任务后面
256 this.tail = this.tail
257 .then(() => this.handler(e))
258 .catch((error) => {
259 console.error('Error processing event:', error)
260 })
261 }
262}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected