Batch messages on the exthost to not freeze ads (#8949)

* batch messages on the exthost to not freeze ads

* clear out messages on query complete
This commit is contained in:
Anthony Dresser
2020-02-20 14:50:13 -08:00
committed by GitHub
parent 8fe0a13b61
commit 4c54b5dbac
11 changed files with 103 additions and 41 deletions

View File

@@ -62,3 +62,26 @@ export class ReverseLookUpMap<K, V> {
return this.forward.size;
}
}
/**
* ASSUMES THAT THE VALUES ARE ALREADY SERIALIZABLE
*/
export function mapToSerializable<T>(map: Map<string, T>): [string, T][] {
const serializable: [string, T][] = [];
map.forEach((value, key) => {
serializable.push([key, value]);
});
return serializable;
}
export function serializableToMap<T>(serializable: [string, T][]): Map<string, T> {
const items = new Map<string, T>();
for (const [key, value] of serializable) {
items.set(key, value);
}
return items;
}