This commit is contained in:
Tony Garnock-Jones 2021-02-23 11:13:41 +01:00
parent f8e6fc4ab6
commit 3d4a6b9bb6
1 changed files with 6 additions and 10 deletions

View File

@ -84,7 +84,12 @@ export class Turn {
spawn(bootProc: (t: Turn) => void, initialAssertions = new IdentitySet<Handle>()): void {
this.tasks.push(() => {
const child = new Actor(extractFromMap(this.actor.outbound, initialAssertions));
const newOutbound: OutboundMap = new Map();
initialAssertions.forEach(key => {
newOutbound.set(key, this.actor.outbound.get(key)!); // we trust initialAssertions
this.actor.outbound.delete(key);
});
const child = new Actor(newOutbound);
child.execute(() => Turn.for(child, bootProc));
});
}
@ -137,12 +142,3 @@ export class Turn {
this.tasks.length && queueMicrotask(() => this.tasks.forEach(f => Turn.for(this.actor, f)));
}
}
function extractFromMap<K, V>(map: Map<K, V>, keys: IdentitySet<K>): Map<K, V> {
const result: Map<K, V> = new Map();
keys.forEach(key => {
if (map.has(key)) result.set(key, map.get(key)!);
map.delete(key);
});
return result;
}