Using flashmq_add_task from the plugin #58
-
Will the task be executed in the context of the calling thread? Let's say in And if I am running FlashMQ on a 4 core CPU and having 4 threads, I guess my task will be executed 4 times - once per each thread. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, the task is placed in the queued tasks list of the current thread's event loop. You can capture And yes, if you have 4 threads, you get four tasks, which you can influence by some kind of static/atomic memory counter, if you want. See here BTW for what Side note:
By 'valid', you imply that accessing |
Beta Was this translation helpful? Give feedback.
Yes, the task is placed in the queued tasks list of the current thread's event loop. You can capture
thread_data
and the same thread will perform the task. You can be sure thethead_data
is not simultanously accessed elsewhere.And yes, if you have 4 threads, you get four tasks, which you can influence by some kind of static/atomic memory counter, if you want.
See here BTW for what
flashmq_add_task
does.Side note:
By 'valid', you imply that accessing
thread_data
of another thread is invalid. It's fine actually, if properly mutexed, but there should be no reason to do it. The only real time it becomes invalid is when youdelete
/free
thread_…