What's the actual use of the Atomics object in ECMAScript?

后端 未结 5 1112
Happy的楠姐
Happy的楠姐 2021-02-07 23:04

The ECMAScript specification defines the Atomics object in the section 24.4.

Among all the global objects this is the more obscure for

5条回答
  •  遇见更好的自我
    2021-02-07 23:29

    If you have some complex computation you may need WebWorkers, in order to your main script may continue his work while heavy things are done in parallel.

    Problem that Atomics solve is how WebVorkers can comunicate between each other (easy, fast and relaible). You can read about ArrayBuffer, SharedArrayBuffer, Atomics and how you can use them for your benifits here.

    You shouldn't bother about it if:

    • You are creating something simple (e.g. shop, forum etc)

    You may need it if:

    • You want to create something complex, memory consuming (e.g figma or google drive)
    • You need that if you are looking to work with WebAssembly or webgl and you want to optimize performance
    • Also you may need it if you want to create some complex Node.js module
    • Or if you are creating complex app via Electron like Skype or Discord

    Thank you Pavlo Mur and Simon Paris for yours answers!

提交回复
热议问题