| 135 | // TODO: check the remark in the standard |
| 136 | template<class F, class... Args> |
| 137 | explicit thread(F&& f, Args&&... args) |
| 138 | : id_{} |
| 139 | { |
| 140 | auto callable = [=](){ |
| 141 | return f(forward<Args>(args)...); |
| 142 | }; |
| 143 | |
| 144 | auto callable_wrapper = new aux::callable_wrapper<decltype(callable)>{move(callable)}; |
| 145 | joinable_wrapper_ = static_cast<aux::joinable_wrapper*>(callable_wrapper); |
| 146 | |
| 147 | id_ = aux::threading::thread::create( |
| 148 | aux::thread_main<decltype(callable_wrapper)>, |
| 149 | *callable_wrapper |
| 150 | ); |
| 151 | |
| 152 | aux::threading::thread::start(id_); |
| 153 | // TODO: fibrils are weird here, 2 returns with same thread ids |
| 154 | } |
| 155 | |
| 156 | thread(const thread&) = delete; |
| 157 | thread& operator=(const thread&) = delete; |