We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage
const dohMathSync = api.doMathAsync.bind(api)
main.mjs
import { Worker } from 'worker_threads' import * as Comlink from 'comlink' const worker = new Worker(new URL('./worker.mjs', import.meta.url)) const api = Comlink.wrap(Comlink.DeasyncEndpoint(worker)) const dohMathSync = api.doMathAsync.bind(api)
worker.mjs
import { parentPort } from 'worker_threads' import * as Comlink from 'comlink' const api = { async doMathAsync() { return 4 } } Comlink.expose(api, Comlink.DeasyncEndpoint(parentPort))
Description
I think DeasyncEndpoint is possible.
DeasyncEndpoint
But I don't know how to wrap comlink with SharedArrayBuffer and Atomics.wait.
comlink
SharedArrayBuffer
Atomics.wait
https://github.com/un-ts/synckit/blob/v0.8.5/src/index.ts#L340-L346
const sharedBuffer = new SharedArrayBuffer(bufferSize) const sharedBufferView = new Int32Array(sharedBuffer) const msg: MainToWorkerMessage<Parameters<T>> = { sharedBuffer, id, args } worker.postMessage(msg) const status = Atomics.wait(sharedBufferView, 0, 0, timeout)
The text was updated successfully, but these errors were encountered:
Sounds like you would find https://github.com/pyodide/synclink useful. cc @hoodmane
Sorry, something went wrong.
@alexmojaki
Thanks for the link.
Seems it is what I want.
pyodide/synclink
No branches or pull requests
Usage
main.mjs
worker.mjs
Description
I think
DeasyncEndpoint
is possible.But I don't know how to wrap
comlink
withSharedArrayBuffer
andAtomics.wait
.https://github.com/un-ts/synckit/blob/v0.8.5/src/index.ts#L340-L346
The text was updated successfully, but these errors were encountered: