Closed ssell closed 8 years ago
Areas that could potentially see a speed up from multithreading:
copyToPixels
methods in D3D11Texture
(edit for more)
Added basic Async functionality in 67218b427150c10039915ba0f8d1ea6d643036e2, example:
Launch single:
auto future = OcularThreads->spawnAsync([](){ OcularLogger->info("Hello World"); });
Launch multiple and wait for them to finish:
OcularThreads->waitForAsyncs(
&OcularThreads->spawnAsyncNow([](){ ... do something ... }),
&OcularThreads->spawnAsyncNow([](){ ... do something ... }),
&OcularThreads->spawnAsyncNow([](){ ... do something ... }));
Moving to 'Put Aside' as functionality beyond Async is currently not needed. Further research in later versions will be needed in order to accurately gauge the full requirements scope (also partly holding off just to see what emerges in C++17).
Require an easy way to initialize new threads to assist certain CPU-based tasks (ie triangle-precision raycasting, etc.).
The resulting class should be as easy to use as:
Should offer support for both standard threads (
std::thread
) and asynchronous processes (std::async
).I have not yet fully decided on whether to create a Thread Manager (ie a
spawn
method that creates a thread at time of call) or a Thread Pool (initialize set amount of threads that then check for tasks to perform). Will probably want to do a bit more research on the topic before settling on an approach as this will be both a fairly core class, but also one that can get nasty very quickly if done incorrectly.Useful resources:
C++ Concurrency in Action: Practical Multithreading https://www.amazon.com/C-Concurrency-Action-Practical-Multithreading/dp/1933988770
Effective Modern C++ - Chapter 7: The Concurrency API https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996
C++11 FAQ: Threads http://www.stroustrup.com/C++11FAQ.html#std-threads
A Thread Pool with C++11 http://progsch.net/wordpress/?p=81
How to check if a std::thread is still running? http://stackoverflow.com/questions/9094422/how-to-check-if-a-stdthread-is-still-running
(edit for more)