summaryrefslogtreecommitdiff
path: root/js/dispatch_minimal.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-08-26 10:58:44 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-08-26 14:56:42 -0400
commitd8ada4d3fcc5dfe7f76103399a1d765fbab2ee45 (patch)
tree2209cb60cd537d1da5c1687ab2b7996655654c06 /js/dispatch_minimal.ts
parent7ff67017f2153eeed393da670777ff85df2801ca (diff)
Port readSync/writeSync ops to minimal
This removes dispatch_flatbuffers as it is now unused. There are still a few places where msg_generated is used: ErrorKind and MediaType. These will be dealt with later.
Diffstat (limited to 'js/dispatch_minimal.ts')
-rw-r--r--js/dispatch_minimal.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/js/dispatch_minimal.ts b/js/dispatch_minimal.ts
index 9a310fd22..3df888e77 100644
--- a/js/dispatch_minimal.ts
+++ b/js/dispatch_minimal.ts
@@ -4,6 +4,9 @@ import * as util from "./util";
import { core } from "./core";
const promiseTableMin = new Map<number, util.Resolvable<number>>();
+// Note it's important that promiseId starts at 1 instead of 0, because sync
+// messages are indicated with promiseId 0. If we ever add wrap around logic for
+// overflows, this should be taken into account.
let _nextPromiseId = 1;
function nextPromiseId(): number {
@@ -63,3 +66,16 @@ export function sendAsyncMinimal(
core.dispatch(opId, scratchBytes, zeroCopy);
return promise;
}
+
+export function sendSyncMinimal(
+ opId: number,
+ arg: number,
+ zeroCopy: Uint8Array
+): number {
+ scratch32[0] = 0; // promiseId 0 indicates sync
+ scratch32[1] = arg;
+ const res = core.dispatch(opId, scratchBytes, zeroCopy)!;
+ const res32 = new Int32Array(res.buffer, res.byteOffset, 3);
+ const resRecord = recordFromBufMinimal(opId, res32);
+ return resRecord.result;
+}