Ticket #2741: 2741_a.patch
File 2741_a.patch, 8.2 KB (added by , 13 years ago) |
---|
-
detail/thread.hpp
114 114 detail::thread_data_ptr thread_info; 115 115 116 116 void start_thread(); 117 117 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 118 void start_thread(thread_attributes& attr); 119 #endif 120 118 121 explicit thread(detail::thread_data_ptr data); 119 122 120 123 detail::thread_data_ptr get_thread_info() const; … … 154 157 { 155 158 start_thread(); 156 159 } 157 160 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 161 template <class F> 162 thread(thread_attributes& attr, F&& f): 163 thread_info(make_thread_info(static_cast<F&&>(f))) 164 { 165 start_thread(attr); 166 } 167 #endif 168 158 169 thread(thread&& other) 159 170 { 160 171 thread_info.swap(other.thread_info); … … 180 191 { 181 192 start_thread(); 182 193 } 194 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 195 template <class F> 196 explicit thread(thread_attributes& attr, F f): 197 thread_info(make_thread_info(f)) 198 { 199 start_thread(attr); 200 } 201 #endif 183 202 #else 184 203 template <class F> 185 204 explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0): … … 187 206 { 188 207 start_thread(); 189 208 } 209 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 210 template <class F> 211 explicit thread(thread_attributes& attr, F f, typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0): 212 thread_info(make_thread_info(f)) 213 { 214 start_thread(attr); 215 } 190 216 #endif 217 #endif 191 218 192 219 template <class F> 193 220 explicit thread(detail::thread_move_t<F> f): … … 196 223 start_thread(); 197 224 } 198 225 226 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 227 template <class F> 228 explicit thread(thread_attributes& attr, detail::thread_move_t<F> f): 229 thread_info(make_thread_info(f)) 230 { 231 start_thread(attr); 232 } 233 #endif 234 199 235 thread(detail::thread_move_t<thread> x) 200 236 { 201 237 thread_info=x->thread_info; … … 228 264 { 229 265 start_thread(); 230 266 } 267 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 268 template <class F,class A1> 269 thread(thread_attributes& attr, F f,A1 a1): 270 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1))) 271 { 272 start_thread(attr); 273 } 274 #endif 231 275 template <class F,class A1,class A2> 232 276 thread(F f,A1 a1,A2 a2): 233 277 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2))) 234 278 { 235 279 start_thread(); 236 280 } 281 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 282 template <class F,class A1,class A2> 283 thread(thread_attributes& attr, F f,A1 a1,A2 a2): 284 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2))) 285 { 286 start_thread(attr); 287 } 288 #endif 237 289 238 290 template <class F,class A1,class A2,class A3> 239 291 thread(F f,A1 a1,A2 a2,A3 a3): … … 241 293 { 242 294 start_thread(); 243 295 } 296 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 297 template <class F,class A1,class A2,class A3> 298 thread(thread_attributes& attr, F f,A1 a1,A2 a2,A3 a3): 299 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3))) 300 { 301 start_thread(attr); 302 } 303 #endif 244 304 245 305 template <class F,class A1,class A2,class A3,class A4> 246 306 thread(F f,A1 a1,A2 a2,A3 a3,A4 a4): … … 248 308 { 249 309 start_thread(); 250 310 } 251 311 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 312 template <class F,class A1,class A2,class A3,class A4> 313 thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4): 314 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4))) 315 { 316 start_thread(attr); 317 } 318 #endif 252 319 template <class F,class A1,class A2,class A3,class A4,class A5> 253 320 thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5): 254 321 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5))) 255 322 { 256 323 start_thread(); 257 324 } 325 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 326 template <class F,class A1,class A2,class A3,class A4,class A5> 327 thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5): 328 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5))) 329 { 330 start_thread(attr); 331 } 332 #endif 258 333 259 334 template <class F,class A1,class A2,class A3,class A4,class A5,class A6> 260 335 thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6): … … 262 337 { 263 338 start_thread(); 264 339 } 340 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 341 template <class F,class A1,class A2,class A3,class A4,class A5,class A6> 342 thread(thread_attributes& attr, F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6): 343 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6))) 344 { 345 start_thread(attr); 346 } 347 #endif 265 348 266 349 template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7> 267 350 thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7): … … 269 352 { 270 353 start_thread(); 271 354 } 355 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 356 template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7> 357 thread(thread_attributes& attr, F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7): 358 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7))) 359 { 360 start_thread(attr); 361 } 362 #endif 272 363 273 364 template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8> 274 365 thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8): … … 276 367 { 277 368 start_thread(); 278 369 } 370 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 371 template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8> 372 thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8): 373 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8))) 374 { 375 start_thread(attr); 376 } 377 #endif 279 378 280 379 template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9> 281 380 thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9): … … 283 382 { 284 383 start_thread(); 285 384 } 385 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 386 template <class F,class A1,class A2,class A3,class A4,class A5,class A6,class A7,class A8,class A9> 387 thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9): 388 thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1,a2,a3,a4,a5,a6,a7,a8,a9))) 389 { 390 start_thread(attr); 391 } 392 #endif 286 393 287 394 void swap(thread& x) 288 395 { -
pthread/thread_data.hpp
18 18 19 19 namespace boost 20 20 { 21 22 #ifdef BOOST_THREAD_HAS_THREAD_ATTR 23 class thread_attributes { 24 public: 25 thread_attributes() { 26 (void)pthread_attr_init(&val_); 27 } 28 ~thread_attributes() { 29 (void)pthread_attr_destroy(&val_); 30 } 31 // stack 32 void set_stack_size(std::size_t size) { 33 (void)pthread_attr_setstacksize(&val_, size); 34 } 35 36 std::size_t get_stack_size() { 37 std::size_t res; 38 (void)pthread_attr_getstacksize(&val_, &res); 39 return res; 40 } 41 42 typedef pthread_attr_t native_handle_type; 43 native_handle_type native_handle() {return val_;} 44 const native_handle_type native_handle() const {return val_;} 45 46 private: 47 pthread_attr_t val_; 48 }; 49 #endif 50 21 51 class thread; 22 52 23 53 namespace detail