Displaying 1 to 4 from 4 results

isolated-threads - NodeJS real threads with shared memory

  •    Javascript

Since the different thread is executed in an isolated instance of v8, you will not be able to use Buffer or require and you will not have access to any kind of event loop functions, like setTimeout or setInterval. When you are passing data between isolates, the data is serialized and copied between threads (read more here). If you with to copy a large amount of data, you should use Typed Arrays (like UInt8Array or Float64Array) with a SharedArrayBuffer backend (if available). In the above example we allocate a w * h * c sized shared buffer, and then use it as a backend for Uint8Array. We do all data manipulation using the uint8 array and then return back the shared one. Upon receiving the shared array from the thread, we reinterpret it into a uint8 array and extract our data.