I have some simple rendering program with a Mainloop
that runs at about 8000 fps on one thread (it does nothing except draw a background) and I wanted to see if another thread rendering would upset the current context without changing it (it didn't to my surprise). I achieved this with this simple code here,
m_Thread = std::thread(Mainloop);
m_Thread.join();
and this code here somehow ran extremely slow, ~30 FPS. I thought this was weird and I remembered in another project I used std::future
for a similar performance-based reason. So I then tried it with std::future
using the following code:
m_Future = std::async(std::launch::async, Mainloop);
m_Future.get();
and this runs just a tiny bit below the single-threaded performance (~7900) fps. Why is std::thread
so much slower than std::future
?
Aucun commentaire:
Enregistrer un commentaire