Silicium
std_threading.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_STD_THREADING_HPP
2 #define SILICIUM_STD_THREADING_HPP
3 
4 #include <silicium/config.hpp>
5 #if SILICIUM_HAS_EXCEPTIONS
6 # include <future>
7 #endif
8 #include <mutex>
9 #include <condition_variable>
10 
11 namespace Si
12 {
14  {
15 #if SILICIUM_HAS_EXCEPTIONS
16  template <class T>
17  struct future
18  {
19  typedef std::future<T> type;
20  };
21  template <class T>
22  struct promise
23  {
24  typedef std::promise<T> type;
25  };
26  template <class Result>
27  struct packaged_task
28  {
29  typedef std::packaged_task<Result ()> type;
30  };
31 #endif
32  typedef std::mutex mutex;
33  typedef std::condition_variable condition_variable;
34  typedef std::unique_lock<std::mutex> unique_lock;
35 #if SILICIUM_HAS_EXCEPTIONS
36  template <class Action, class ...Args>
37  static auto launch_async(Action &&action, Args &&...args) -> std::future<decltype(action(std::forward<Args>(args)...))>
38  {
39  return std::async(std::launch::async, std::forward<Action>(action), std::forward<Args>(args)...);
40  }
41 #endif
42  };
43 }
44 
45 #endif
std::condition_variable condition_variable
Definition: std_threading.hpp:33
Definition: absolute_path.hpp:19
Definition: std_threading.hpp:13
std::unique_lock< std::mutex > unique_lock
Definition: std_threading.hpp:34
std::mutex mutex
Definition: std_threading.hpp:32