mardi 6 janvier 2015

Do std::async and std::future scale well on iOS and Android platforms?

I have a 2D particle system for a game engine in which I want to decouple the update loop of the particles from the main thread. I am using a thread pool implemented with boost::asio and am splitting up all the tasks into several stages and then combining the results on the main thread. This works well for me, and guarantees a limit on the total threads I have allowed for the pool (which is shared by all particle emitters which fire their own tasks independently).


I have read a lot of articles discussing std::async and std::future. This seems to be totally reasonable on windows or linux type systems where thread creation is well managed by the OS and memory is bountiful. But it seems like very little focus is spent on discussing this kind of thing in a mobile platform where thread creation may be costly. Because I am not sure how many threads might be made on these platforms it seems hard to rely on std::async in contexts where I don't know how many async calls may be in action at a given time (if each creates its own thread).


http://ift.tt/1HHZImo


I would like to hear from an individual with multithreaded C++ mobile development experience. My question in summary is this:


If I create 20 particle effects, each with 4 concurrent async tasks, will this result in 100 threads each taking .5 mb of ram? Or does async have some magic support for being intelligent with thread creation and task sharing?


Alternatively will async bog down the main thread (if not being explicit with the thread creation rule) effectively lagging my gameplay for relatively low-priority particle effects?


If so, what context is async actually useful in on mobile as it seems thread creation is something you'd like to be a little more explicit about on these devices.


Aucun commentaire:

Enregistrer un commentaire