mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-09-15 12:42:21 +02:00
16 lines
409 B
JavaScript
16 lines
409 B
JavaScript
/** Cooperative render generations shared by synchronous and future async renderers. */
|
|
export function createRenderGeneration() {
|
|
let generation = 0;
|
|
return {
|
|
begin() {
|
|
const id = ++generation;
|
|
return {
|
|
id,
|
|
isCurrent: () => id === generation,
|
|
cancel: () => { if (id === generation) generation += 1; },
|
|
};
|
|
},
|
|
invalidate() { generation += 1; },
|
|
};
|
|
}
|