thread pool example

Apr 28, 2015 at 2:47 PM
Hi,

I'm trying to figure out how to use a thread pool to divvy up the work I want done. The group_by examples in the the SDK seem to create new threads - I don't want to do that. I want to do something like calculating Pi using a thread pool. There must be a way to do this.

Thanks
Coordinator
Apr 28, 2015 at 5:07 PM
The event_loop scheduler is a simple round-robin fixed-size thread pool. the observe_on_event_loop() coordination can be passed into the subscribe_on() or observe_on() operators.

For more complex and tuned thread pools it would be great to have schedulers contributed that used Windows ThreadPool api or Apple's GCD. A sheduler just has two methods to implement, but the semantic of a worker is that even if two items are scheduled for the same time they are run, one after the other, starting at the time.
Apr 28, 2015 at 7:13 PM
Right, what I am working on is image processing. We have state variables, say a contrast adjustment or brightness, whatever. I want to use Rx to "stream" these state changes down to our filters. This takes place on a background thread, Rx works well for this. But our filters could use the Rx scheduler also, to process image tiles in a thread pool. This would unify the threading model across the application. But looking at the examples I haven't figured out how to do this. I cannot be creating tons of threads - I need a pool. I want to divvy up my tiles among the available processors. I assume it would be similar to the Pi calculation example without creating new threads.

If this works, then I would like to implement TBB, PPL, and GCD, but that is another matter.

Right now I am just trying to get a proof of concept and I am pretty low on the Rx learning curve. Any insight would be helpful, but I expect I will figure out something.