summaryrefslogtreecommitdiff
path: root/js/dispatch_minimal.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-08-21 20:42:48 -0400
committerGitHub <noreply@github.com>2019-08-21 20:42:48 -0400
commitbdc97b3976786bb744a27e59b0f4f28554a682df (patch)
treebf4635ad903de542c10620e95adb72eee03d9204 /js/dispatch_minimal.ts
parentb764d1b8ffc4bf5e2ab89bdbd978d708a6da0f24 (diff)
Organize dispatch a bit (#2796)
Just some clean up reorganization around flatbuffer/minimal dispatch code. This is prep for adding a JSON dispatcher.
Diffstat (limited to 'js/dispatch_minimal.ts')
-rw-r--r--js/dispatch_minimal.ts13
1 files changed, 5 insertions, 8 deletions
diff --git a/js/dispatch_minimal.ts b/js/dispatch_minimal.ts
index df0a290b2..fc3fc61b9 100644
--- a/js/dispatch_minimal.ts
+++ b/js/dispatch_minimal.ts
@@ -4,9 +4,9 @@ import * as util from "./util";
import { core } from "./core";
const promiseTableMin = new Map<number, util.Resolvable<number>>();
-let _nextPromiseId = 0;
+let _nextPromiseId = 1;
-export function nextPromiseId(): number {
+function nextPromiseId(): number {
return _nextPromiseId++;
}
@@ -40,12 +40,9 @@ const scratchBytes = new Uint8Array(
);
util.assert(scratchBytes.byteLength === scratch32.length * 4);
-export function handleAsyncMsgFromRustMinimal(
- ui8: Uint8Array,
- record: RecordMinimal
-): void {
- // Fast and new
- util.log("minimal handleAsyncMsgFromRust ", ui8.length);
+export function handleAsyncMsgFromRust(opId: number, ui8: Uint8Array): void {
+ const buf32 = new Int32Array(ui8.buffer, ui8.byteOffset, ui8.byteLength / 4);
+ const record = recordFromBufMinimal(opId, buf32);
const { promiseId, result } = record;
const promise = promiseTableMin.get(promiseId);
promiseTableMin.delete(promiseId);