Index: detail/thread.hpp =================================================================== --- detail/thread.hpp (revision 53346) +++ detail/thread.hpp (working copy) @@ -114,7 +114,10 @@ detail::thread_data_ptr thread_info; void start_thread(); - +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + void start_thread(thread_attributes& attr); +#endif + explicit thread(detail::thread_data_ptr data); detail::thread_data_ptr get_thread_info() const; @@ -154,7 +157,15 @@ { start_thread(); } - +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr, F&& f): + thread_info(make_thread_info(static_cast(f))) + { + start_thread(attr); + } +#endif + thread(thread&& other) { thread_info.swap(other.thread_info); @@ -180,6 +191,14 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + explicit thread(thread_attributes& attr, F f): + thread_info(make_thread_info(f)) + { + start_thread(attr); + } +#endif #else template explicit thread(F f,typename disable_if >, dummy* >::type=0): @@ -187,7 +206,15 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + explicit thread(thread_attributes& attr, F f, typename disable_if >, dummy* >::type=0): + thread_info(make_thread_info(f)) + { + start_thread(attr); + } #endif +#endif template explicit thread(detail::thread_move_t f): @@ -196,6 +223,15 @@ start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + explicit thread(thread_attributes& attr, detail::thread_move_t f): + thread_info(make_thread_info(f)) + { + start_thread(attr); + } +#endif + thread(detail::thread_move_t x) { thread_info=x->thread_info; @@ -228,12 +264,28 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr, F f,A1 a1): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2): thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2))) { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr, F f,A1 a1,A2 a2): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3): @@ -241,6 +293,14 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr, F f,A1 a1,A2 a2,A3 a3): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3,A4 a4): @@ -248,13 +308,28 @@ { start_thread(); } - +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5): thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5))) { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6): @@ -262,6 +337,14 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr, F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7): @@ -269,6 +352,14 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr, F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6,a7))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8): @@ -276,6 +367,14 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6,a7,a8))) + { + start_thread(attr); + } +#endif template thread(F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9): @@ -283,6 +382,14 @@ { start_thread(); } +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + template + thread(thread_attributes& attr,F f,A1 a1,A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9): + thread_info(make_thread_info(boost::bind(boost::type(),f,a1,a2,a3,a4,a5,a6,a7,a8,a9))) + { + start_thread(attr); + } +#endif void swap(thread& x) { Index: pthread/thread_data.hpp =================================================================== --- pthread/thread_data.hpp (revision 53346) +++ pthread/thread_data.hpp (working copy) @@ -18,6 +18,36 @@ namespace boost { + +#ifdef BOOST_THREAD_HAS_THREAD_ATTR + class thread_attributes { + public: + thread_attributes() { + (void)pthread_attr_init(&val_); + } + ~thread_attributes() { + (void)pthread_attr_destroy(&val_); + } + // stack + void set_stack_size(std::size_t size) { + (void)pthread_attr_setstacksize(&val_, size); + } + + std::size_t get_stack_size() { + std::size_t res; + (void)pthread_attr_getstacksize(&val_, &res); + return res; + } + + typedef pthread_attr_t native_handle_type; + native_handle_type native_handle() {return val_;} + const native_handle_type native_handle() const {return val_;} + + private: + pthread_attr_t val_; + }; +#endif + class thread; namespace detail