Skip to content

Using flashmq_add_task from the plugin #58

Closed Answered by wiebeytec
slavslavov asked this question in Q&A
Discussion options

You must be logged in to vote

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 the thead_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:

and will thread_data be valid at this point?

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 you delete / free thread_…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by slavslavov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants