How do I share new data between old threads?
Hm. That is a very ambiguous question. Essentially, all shared variables are accessible from all threads. So, as soon as you assign a new value to an existing shared variable, it (the new value), becomes available to all other threads the next time they get a timeslice.
Of course, that then raises the questions:
One way to notify threads of the availability of new values is to use the cond_* functions in threads::shared, but that is often the hardest and most error prone way of doing things. There are all sort of caveats to do with missed signals, deadlocks etc. Thread::Queue is usually far easier to both use, and to reason about.
To be able to give you a good answer to the problem underlying your question, we would need to know a little more about that problem. I can sit here and try t dream up scenarios for what you are trying to achieve, and come op with half a dozen that would all completely miss the mark. In other words, please post a little code demonstrating the problem you are trying to tackle, then we stand a better than even chance of offering you an appropriate solution.
In reply to Re^9: does threads (still) memleak?
by BrowserUk
in thread does threads (still) memleak?
by faxm0dem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |