(ES6) ES6 (2016)

Atomic (AT05)

   1:  import { parentPort } from 'worker_threads';
   2:  
   3:  // Listen for messages from the main thread
   4:  parentPort.on('message', (event) => {
   5:      const sab = event.sab; // Extract the SharedArrayBuffer from the message
   6:      const i32 = new Int32Array(sab);
   7:  
   8:      console.log(`Worker started and waiting...`);
   9:  
  10:      // Wait for the main thread to notify
  11:      Atomics.wait(i32, 0, 0); // Blocks until notified
  12:      console.log(`Worker awakened with value: ${i32[0]}`);
  13:  });



Worker thread to Atomics.notify() 





Atomic context:






ES6 context:



Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23>  <24>  <25
Link to this page: http://www.vb-net.com/JavascriptES6/AT05.htm
<TAGS>  <ARTICLES>  <FRONT>  <CORE>  <MVC>  <ASP>  <NET>  <DATA>  <TASK>  <XML>  <KIOSK>  <NOTES>  <SQL>  <LINUX>  <MONO>  <FREEWARE>  <DOCS> <TRAVELS> <FLOWERS> <RESUME> < THANKS ME>