JayBeams  0.1
Another project to have fun coding.
launch_thread.hpp
Go to the documentation of this file.
1 #ifndef jb_launch_thread_hpp
2 #define jb_launch_thread_hpp
3 
5 #include <thread>
6 #include <type_traits>
7 
8 namespace jb {
9 
10 /**
11  * Create a new thread, configure it as desired, and then call a
12  * user-defined function.
13  */
14 template <typename Function, typename... A>
16  std::thread& t, thread_config const& config, Function&& f, A&&... a) {
18  config, std::bind(std::forward<Function>(f), std::forward<A>(a)...));
19 
20  std::thread tmp(c);
21  t = std::move(tmp);
22 };
23 
24 } // namespace jb
25 
26 #endif // jb_launch_thread_hpp
Hold the configuration to initialize threads.
void launch_thread(std::thread &t, thread_config const &config, Function &&f, A &&... a)
Create a new thread, configure it as desired, and then call a user-defined function.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7
thread_setup_wrapper< Callable > make_thread_setup_wrapper(thread_config const &config, Callable &&c)
Create the right type of thread_setup_wrapper<>.