Created
February 11, 2021 18:42
-
-
Save jasonLaster/a3f106c57a51f05518809e07a6c86718 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/control/worker.ts b/src/control/worker.ts | |
| index 7edb8244..f9f8ea05 100644 | |
| --- a/src/control/worker.ts | |
| +++ b/src/control/worker.ts | |
| @@ -179,7 +179,7 @@ const gMappedLocationsCache: PromiseMap<Location, Location[]> = new PromiseMap({ | |
| getKey: locationKey, | |
| async computeResult(generatedLocation) { | |
| - const { mapped } = await sendWorkerCommand("getMappedLocations", { | |
| + const { mapped } = await batchedSendWorkerCommand("getMappedLocations", { | |
| generatedLocation, | |
| }); | |
| return mapped; | |
| diff --git a/src/control/worker/workermain.ts b/src/control/worker/workermain.ts | |
| index 7ab5ee29..fd7c2b17 100644 | |
| --- a/src/control/worker/workermain.ts | |
| +++ b/src/control/worker/workermain.ts | |
| @@ -29,6 +29,21 @@ import { Location } from "@recordreplay/protocol"; | |
| addLogContext({ controlId: process.env.CONTROL_ID }); | |
| +setBatchedCommandHandler(async messages => { | |
| + const results = await Promise.all( | |
| + messages.map((kind, params) => { | |
| + const handler = (gWorkerCommands as any)[kind]; | |
| + if (!handler) { | |
| + throw new Error("WorkerUnknownCommand"); | |
| + } | |
| + | |
| + return handler(params); | |
| + }) | |
| + ); | |
| + | |
| + return results; | |
| +}); | |
| + | |
| setCommandHandler(async (kind, params) => { | |
| const handler = (gWorkerCommands as any)[kind]; | |
| if (!handler) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment