Skip to content

chicoxyzzy/sync-calls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a proof of concept of exposing a sync calls API from the Web Worker

The problem

It's only possible to make async calls when a Web Worker sends messages to the main thread or other Worker threads, ie postMessage and addEventListener. Sometimes we want to use synchronous calls instead for various reasons.

Solution

It is possible to use SharedArrayBuffer, Atomics.wait and Atomics.notify to achieve that.

Files:

  • main.js — main thread which exposes API to the Worker thread
  • worker.js — Worker thread with sync calls
  • api.js — this file includes both main thread logic and Worker thread logic implementation

In general, this approach can help turn asynchronous calls into synchronous calls.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published