Recently, I tried to find a library for stream processing of parallel tasks. Ideally, a simple interface that calls a function in a stream. At any time, there are n number of threads, some of which are faster than others, and arrive at different times.
At first I tried to use Rx, which is great in C ++. I also studied Blocks and TBB, but they are platform dependent. For my prototype, I need to remain independent of the platform, because we do not know what it will work for, and we can change when making decisions.
There are many things in C ++ 11 for streaming processing and concurrency, and I have found some examples like this for thread pools.
https://github.com/bilash/threadpool
Similar projects use the same lambda expressions with std :: thread and std :: mutex.
It looks perfect for what I need. There are some problems. Pools start with a certain number of threads, and tasks are queued until the thread becomes free.
How to add new threads? Delete expired threads? (.join () ??)
Obviously, this is much simpler for a known number of threads, since they can be initialized in ctor and then join () in dtor.
Any tips or pointers from someone who has experience with C ++ concurrency?
source
share