* Get or create the state bucket for a context.
(
contextId: SchedulerContextId,
)
| 54 | * Get or create the state bucket for a context. |
| 55 | */ |
| 56 | private getOrCreateContext( |
| 57 | contextId: SchedulerContextId, |
| 58 | ): SchedulerContextState { |
| 59 | let context = this.contexts.get(contextId) |
| 60 | if (!context) { |
| 61 | context = { |
| 62 | queue: [], |
| 63 | jobs: new Map(), |
| 64 | dependencies: new Map(), |
| 65 | completed: new Set(), |
| 66 | } |
| 67 | this.contexts.set(contextId, context) |
| 68 | } |
| 69 | return context |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Schedule work. Without a context id, executes immediately. |