diff --git a/boost/thread/detail/thread.hpp b/boost/thread/detail/thread.hpp
index 26224ba..3db4b88 100644
|
a
|
b
|
namespace boost
|
| 117 | 117 | |
| 118 | 118 | detail::thread_data_ptr thread_info; |
| 119 | 119 | |
| 120 | | void start_thread(); |
| 121 | | |
| 122 | 120 | explicit thread(detail::thread_data_ptr data); |
| 123 | 121 | |
| 124 | 122 | detail::thread_data_ptr get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const; |
| … |
… |
namespace boost
|
| 147 | 145 | |
| 148 | 146 | #endif |
| 149 | 147 | struct dummy; |
| | 148 | |
| | 149 | protected: |
| | 150 | template <class F> |
| | 151 | void set_thread_main_function(F f) |
| | 152 | { |
| | 153 | thread_info = make_thread_info(f); |
| | 154 | } |
| | 155 | |
| | 156 | void start_thread(unsigned int stack_size = 0); |
| | 157 | |
| 150 | 158 | public: |
| 151 | 159 | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
| 152 | 160 | thread(const volatile thread&); |
| 153 | 161 | #endif |
| 154 | 162 | thread(); |
| 155 | | ~thread(); |
| | 163 | virtual ~thread(); |
| 156 | 164 | |
| 157 | 165 | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 158 | 166 | #ifdef BOOST_MSVC |
| … |
… |
namespace boost
|
| 164 | 172 | } |
| 165 | 173 | #else |
| 166 | 174 | template <class F> |
| 167 | | thread(F&& f): |
| | 175 | thread(F&& f, unsigned int stack_size = 0): |
| 168 | 176 | thread_info(make_thread_info(static_cast<F&&>(f))) |
| 169 | 177 | { |
| 170 | | start_thread(); |
| | 178 | start_thread(stack_size); |
| 171 | 179 | } |
| 172 | 180 | #endif |
| 173 | 181 | |
| … |
… |
namespace boost
|
| 191 | 199 | #else |
| 192 | 200 | #ifdef BOOST_NO_SFINAE |
| 193 | 201 | template <class F> |
| 194 | | explicit thread(F f): |
| | 202 | explicit thread(F f, unsigned int stack_size = 0): |
| 195 | 203 | thread_info(make_thread_info(f)) |
| 196 | 204 | { |
| 197 | | start_thread(); |
| | 205 | start_thread(stack_size); |
| 198 | 206 | } |
| 199 | 207 | #else |
| 200 | 208 | template <class F> |
| 201 | | explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0): |
| | 209 | explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0, unsigned int stack_size = 0): |
| 202 | 210 | thread_info(make_thread_info(f)) |
| 203 | 211 | { |
| 204 | | start_thread(); |
| | 212 | start_thread(stack_size); |
| 205 | 213 | } |
| 206 | 214 | #endif |
| 207 | 215 | |
| 208 | 216 | template <class F> |
| 209 | | explicit thread(detail::thread_move_t<F> f): |
| | 217 | explicit thread(detail::thread_move_t<F> f, unsigned int stack_size = 0): |
| 210 | 218 | thread_info(make_thread_info(f)) |
| 211 | 219 | { |
| 212 | | start_thread(); |
| | 220 | start_thread(stack_size); |
| 213 | 221 | } |
| 214 | 222 | |
| 215 | 223 | thread(detail::thread_move_t<thread> x) |
| … |
… |
namespace boost
|
| 246 | 254 | #endif |
| 247 | 255 | |
| 248 | 256 | template <class F,class A1> |
| 249 | | thread(F f,A1 a1): |
| | 257 | thread(F f,A1 a1, unsigned int stack_size = 0): |
| 250 | 258 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1))) |
| 251 | 259 | { |
| 252 | | start_thread(); |
| | 260 | start_thread(stack_size); |
| 253 | 261 | } |
| 254 | 262 | template <class F,class A1,class A2> |
| 255 | | thread(F f,A1 a1,A2 a2): |
| | 263 | thread(F f,A1 a1,A2 a2, unsigned int stack_size = 0): |
| 256 | 264 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2))) |
| 257 | 265 | { |
| 258 | | start_thread(); |
| | 266 | start_thread(stack_size); |
| 259 | 267 | } |
| 260 | 268 | |
| 261 | 269 | template <class F,class A1,class A2,class A3> |
| 262 | | thread(F f,A1 a1,A2 a2,A3 a3): |
| | 270 | thread(F f,A1 a1,A2 a2,A3 a3, unsigned int stack_size = 0): |
| 263 | 271 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3))) |
| 264 | 272 | { |
| 265 | | start_thread(); |
| | 273 | start_thread(stack_size); |
| 266 | 274 | } |
| 267 | 275 | |
| 268 | 276 | template <class F,class A1,class A2,class A3,class A4> |
| 269 | | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4): |
| | 277 | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4, unsigned int stack_size = 0): |
| 270 | 278 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4))) |
| 271 | 279 | { |
| 272 | | start_thread(); |
| | 280 | start_thread(stack_size); |
| 273 | 281 | } |
| 274 | 282 | |
| 275 | 283 | template <class F,class A1,class A2,class A3,class A4,class A5> |
| 276 | | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5): |
| | 284 | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5, unsigned int stack_size = 0): |
| 277 | 285 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5))) |
| 278 | 286 | { |
| 279 | | start_thread(); |
| | 287 | start_thread(stack_size); |
| 280 | 288 | } |
| 281 | 289 | |
| 282 | 290 | template <class F,class A1,class A2,class A3,class A4,class A5,class A6> |
| 283 | | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6): |
| | 291 | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6, unsigned int stack_size = 0): |
| 284 | 292 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6))) |
| 285 | 293 | { |
| 286 | | start_thread(); |
| | 294 | start_thread(stack_size); |
| 287 | 295 | } |
| 288 | 296 | |
| 289 | 297 | template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7> |
| 290 | | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7): |
| | 298 | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7, unsigned int stack_size = 0): |
| 291 | 299 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7))) |
| 292 | 300 | { |
| 293 | | start_thread(); |
| | 301 | start_thread(stack_size); |
| 294 | 302 | } |
| 295 | 303 | |
| 296 | 304 | template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8> |
| 297 | | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8): |
| | 305 | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8, unsigned int stack_size = 0): |
| 298 | 306 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8))) |
| 299 | 307 | { |
| 300 | | start_thread(); |
| | 308 | start_thread(stack_size); |
| 301 | 309 | } |
| 302 | 310 | |
| 303 | 311 | template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9> |
| 304 | | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9): |
| | 312 | thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9, unsigned int stack_size = 0): |
| 305 | 313 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8,a9))) |
| 306 | 314 | { |
| 307 | | start_thread(); |
| | 315 | start_thread(stack_size); |
| 308 | 316 | } |
| 309 | 317 | |
| 310 | 318 | void swap(thread& x) |
diff --git a/libs/thread/src/pthread/thread.cpp b/libs/thread/src/pthread/thread.cpp
index 4ff40a9..7571c9a 100644
|
a
|
b
|
namespace boost
|
| 180 | 180 | thread::thread() |
| 181 | 181 | {} |
| 182 | 182 | |
| 183 | | void thread::start_thread() |
| | 183 | void thread::start_thread(unsigned int stack_size) |
| 184 | 184 | { |
| | 185 | /* FIXME: Linux-only. Breaks Win32. */ |
| 185 | 186 | thread_info->self=thread_info; |
| 186 | | int const res = pthread_create(&thread_info->thread_handle, 0, &thread_proxy, thread_info.get()); |
| | 187 | pthread_attr_t attr; |
| | 188 | int res = pthread_attr_init(&attr); |
| | 189 | if (res != 0) { |
| | 190 | throw thread_resource_error(); |
| | 191 | } |
| | 192 | if (stack_size > 0) { |
| | 193 | res = pthread_attr_setstacksize(&attr, stack_size); |
| | 194 | if (res != 0) { |
| | 195 | pthread_attr_destroy(&attr); |
| | 196 | throw thread_resource_error(); |
| | 197 | } |
| | 198 | } |
| | 199 | |
| | 200 | res = pthread_create(&thread_info->thread_handle, &attr, &thread_proxy, thread_info.get()); |
| | 201 | pthread_attr_destroy(&attr); |
| 187 | 202 | if (res != 0) |
| 188 | 203 | { |
| 189 | 204 | thread_info->self.reset(); |