Questions tagged [worker-thread]

180 questions
29
votes
3 answers

Node.js worker threads shared object/store

So, I was reading some stuff regarding Node.js and I was amazed when I came across Worker Threads. Having threads in my opinion is a great plus especially if you combine it with shared memory access. As you might think already ->…
0x_Anakin
  • 3,229
  • 5
  • 47
  • 86
24
votes
1 answer

Push vs Pull Queues on Google App Engine

So far, no one (not even the GAE docs) has been able to give me a really clear description of what the difference is between a push queue and a pull queue. My understanding is that the Task Queue API allows you to define task queues where work can…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
23
votes
1 answer

When is better using clustering or worker_threads?

I have been reading about multi-processing on NodeJS to get the best understanding and try to get a good performance in heavy environments with my code. Although I understand the basic purpose and concept for the different ways to take profit of the…
jaume
  • 493
  • 1
  • 7
  • 17
22
votes
2 answers

nodejs - DataCloneError: function () { [native code] } could not be cloned

I'm trying to spawn threads (using the new Nodejs module 'worker_threads') and pass to each of them a complex object which is the 'page' object of a Puppeteer browser.newPage() instance. I tried both using workerData and MessageChannels - which,…
cub33
  • 598
  • 1
  • 4
  • 12
14
votes
1 answer

Android: multiple intentservices or one intentservice with multiple intents?

I'm a little confused about intentService. The docs say that if you send an intentService multiple tasks (intents) then it will execute them one after the other on one separate thread. My question is - is it possible to have multiple intentService…
10
votes
6 answers

Proper way to have an endless worker thread?

I have an object that requires a lot of initialization (1-2 seconds on a beefy machine). Though once it is initialized it only takes about 20 miliseconds to do a typical "job" In order to prevent it from being re-initialized every time an app wants…
Neil N
  • 24,862
  • 16
  • 85
  • 145
9
votes
1 answer

How to pass class instances with function through worker_thread.Worker to use function?

To contextualize, I would like to use class instances functions through a Worker Thread from NodeJS "worker_thread" module. In one main.js file I declare a class and instanciate a new Worker passing the new instance through the workerData…
8
votes
2 answers

How to Prevent a Node.js 12 worker Thread from terminating immediately?

I have a Node.js application running an Express server and a worker thread that does something at regular intervals. When the server is stopped, I need to clean up a connection to an external system that is opened by the worker thread when it…
Patrick Hund
  • 19,163
  • 11
  • 66
  • 95
8
votes
2 answers

How do I create a direct communication channel between two worker threads in Node.js

Is there a way to create a direct communication channel using new MessageChannel between two worker threads? For Eg: There is a main thread P that I have created using the worker_thread API, which creates two worker threads W1 and W2 P -> W1 ->…
tusharmath
  • 10,622
  • 12
  • 56
  • 83
8
votes
2 answers

C#, Event Handlers and Threading

I'm writing a little chat app, and I have this event handler: void o_Typing(object sender, EventArgs e) { MessageBox.Show("Fired!"); this.Text = "Fired!"; } o_Typing is a method in a class derived from TabPage. Basically, I want each…
user47322
7
votes
1 answer

node worker_threads console.log comes after postMessage

node v10.16.3 I was running an worker_threads example from node official doc. I made some changes as want to test share variables. Here is an example work-thread.js const { Worker, isMainThread, parentPort, workerData } =…
Zhao Xiaojing
  • 71
  • 1
  • 4
7
votes
1 answer

PostMessage from WorkerThread to Main Window in MFC

I have a MFC application, which has a worker thread, what I want to do is to post message from worker thread to the Main GUI thread to update some status messages on GUI. What I have done so far is Registered a new window message //custom…
6
votes
1 answer

Is there a way to safely bind texture using OpenGL in a worker thread of Qt GUI application?

I am currently working on a GUI software project for visualizing 3D scenes using Qt. The GUI allows user to load batches of 3D data files such as .obj with some .mtl support and .stl as well as 2D image files into the scene as SceneObject-class…
ksming
  • 1,422
  • 1
  • 16
  • 26
6
votes
2 answers

How worker threads works in Nodejs?

Nodejs can not have a built-in thread API like java and .net do. If threads are added, the nature of the language itself will change. It’s not possible to add threads as a new set of available classes or functions. Nodejs 10.x added worker…
Sandeep Patel
  • 4,815
  • 3
  • 21
  • 37
6
votes
2 answers

Nodejs and Express, use res.send() from a worker thread

In Nodejs, using Express as a server, I offload a heavy computation onto a worker thread. From the main application, I call the worker thread like this: // file: main.js const { Worker } = require("worker_threads"); function runService(fileName,…
Hendrik Jan
  • 4,396
  • 8
  • 39
  • 75
1
2 3
11 12