Only in boost_1_48_0/boost/thread/detail: move.hpp
diff -ur boost_1_48_0/boost/thread/detail/thread.hpp boost_1_48_0_patched/boost/thread/detail/thread.hpp
|
old
|
new
|
|
| 9 | 9 | #ifndef BOOST_NO_IOSTREAM |
| 10 | 10 | #include <ostream> |
| 11 | 11 | #endif |
| 12 | | #include <boost/thread/detail/move.hpp> |
| | 12 | #include <boost/move/move.hpp> |
| 13 | 13 | #include <boost/thread/mutex.hpp> |
| 14 | 14 | #include <boost/thread/xtime.hpp> |
| 15 | 15 | #include <boost/thread/detail/thread_heap_alloc.hpp> |
| … |
… |
|
| 22 | 22 | #include <boost/bind.hpp> |
| 23 | 23 | #include <stdlib.h> |
| 24 | 24 | #include <memory> |
| 25 | | #include <boost/utility/enable_if.hpp> |
| 26 | | #include <boost/type_traits/remove_reference.hpp> |
| | 25 | #include <boost/type_traits/decay.hpp> |
| 27 | 26 | |
| 28 | 27 | #include <boost/config/abi_prefix.hpp> |
| 29 | 28 | |
| … |
… |
|
| 41 | 40 | public detail::thread_data_base |
| 42 | 41 | { |
| 43 | 42 | public: |
| 44 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 45 | | thread_data(F&& f_): |
| 46 | | f(static_cast<F&&>(f_)) |
| | 43 | thread_data(BOOST_RV_REF(F) f_): |
| | 44 | f(boost::move(f_)) |
| 47 | 45 | {} |
| 48 | | thread_data(F& f_): |
| | 46 | thread_data(F const& f_): |
| 49 | 47 | f(f_) |
| 50 | 48 | {} |
| 51 | | #else |
| 52 | | thread_data(F f_): |
| 53 | | f(f_) |
| 54 | | {} |
| 55 | | thread_data(detail::thread_move_t<F> f_): |
| 56 | | f(f_) |
| 57 | | {} |
| 58 | | #endif |
| 59 | 49 | void run() |
| 60 | 50 | { |
| 61 | 51 | f(); |
| … |
… |
|
| 110 | 100 | class BOOST_THREAD_DECL thread |
| 111 | 101 | { |
| 112 | 102 | private: |
| 113 | | thread(thread&); |
| 114 | | thread& operator=(thread&); |
| 115 | | |
| | 103 | BOOST_MOVABLE_BUT_NOT_COPYABLE(thread) |
| 116 | 104 | void release_handle(); |
| 117 | 105 | |
| 118 | 106 | detail::thread_data_ptr thread_info; |
| … |
… |
|
| 123 | 111 | |
| 124 | 112 | detail::thread_data_ptr get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const; |
| 125 | 113 | |
| | 114 | |
| 126 | 115 | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 127 | 116 | template<typename F> |
| 128 | 117 | static inline detail::thread_data_ptr make_thread_info(F&& f) |
| 129 | 118 | { |
| 130 | | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >(static_cast<F&&>(f))); |
| 131 | | } |
| 132 | | static inline detail::thread_data_ptr make_thread_info(void (*f)()) |
| 133 | | { |
| 134 | | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<void(*)()> >(static_cast<void(*&&)()>(f))); |
| | 119 | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::decay<F>::type> >(boost::forward<F>(f))); |
| 135 | 120 | } |
| 136 | 121 | #else |
| | 122 | struct dummy; |
| 137 | 123 | template<typename F> |
| 138 | | static inline detail::thread_data_ptr make_thread_info(F f) |
| | 124 | static inline detail::thread_data_ptr make_thread_info(F& f) |
| 139 | 125 | { |
| 140 | 126 | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<F> >(f)); |
| 141 | 127 | } |
| | 128 | |
| 142 | 129 | template<typename F> |
| 143 | | static inline detail::thread_data_ptr make_thread_info(boost::detail::thread_move_t<F> f) |
| | 130 | static inline detail::thread_data_ptr make_thread_info(BOOST_RV_REF(F) f) |
| 144 | 131 | { |
| 145 | | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<F> >(f)); |
| | 132 | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<F> >(boost::move(f))); |
| 146 | 133 | } |
| 147 | | |
| 148 | 134 | #endif |
| 149 | | struct dummy; |
| | 135 | |
| 150 | 136 | public: |
| 151 | 137 | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
| 152 | 138 | thread(const volatile thread&); |
| … |
… |
|
| 155 | 141 | ~thread(); |
| 156 | 142 | |
| 157 | 143 | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 158 | | #ifdef BOOST_MSVC |
| 159 | | template <class F> |
| 160 | | explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0): |
| 161 | | thread_info(make_thread_info(static_cast<F&&>(f))) |
| 162 | | { |
| 163 | | start_thread(); |
| 164 | | } |
| 165 | | #else |
| 166 | | template <class F> |
| 167 | | thread(F&& f): |
| 168 | | thread_info(make_thread_info(static_cast<F&&>(f))) |
| 169 | | { |
| 170 | | start_thread(); |
| 171 | | } |
| 172 | | #endif |
| 173 | | |
| 174 | | thread(thread&& other) |
| 175 | | { |
| 176 | | thread_info.swap(other.thread_info); |
| 177 | | } |
| 178 | | |
| 179 | 144 | thread& operator=(thread&& other) |
| 180 | 145 | { |
| 181 | 146 | thread_info=other.thread_info; |
| 182 | 147 | other.thread_info.reset(); |
| 183 | 148 | return *this; |
| 184 | 149 | } |
| 185 | | |
| 186 | | thread&& move() |
| 187 | | { |
| 188 | | return static_cast<thread&&>(*this); |
| 189 | | } |
| 190 | | |
| 191 | | #else |
| 192 | | #ifdef BOOST_NO_SFINAE |
| 193 | 150 | template <class F> |
| 194 | | explicit thread(F f): |
| 195 | | thread_info(make_thread_info(f)) |
| | 151 | explicit thread(F&& f): |
| | 152 | thread_info(make_thread_info(boost::forward<F>(f))) |
| 196 | 153 | { |
| 197 | 154 | start_thread(); |
| 198 | 155 | } |
| 199 | 156 | #else |
| 200 | | template <class F> |
| 201 | | explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0): |
| 202 | | thread_info(make_thread_info(f)) |
| 203 | | { |
| 204 | | start_thread(); |
| 205 | | } |
| 206 | | #endif |
| 207 | | |
| 208 | | template <class F> |
| 209 | | explicit thread(detail::thread_move_t<F> f): |
| 210 | | thread_info(make_thread_info(f)) |
| 211 | | { |
| 212 | | start_thread(); |
| 213 | | } |
| 214 | | |
| 215 | | thread(detail::thread_move_t<thread> x) |
| 216 | | { |
| 217 | | thread_info=x->thread_info; |
| 218 | | x->thread_info.reset(); |
| 219 | | } |
| 220 | | |
| 221 | 157 | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
| 222 | | thread& operator=(thread x) |
| | 158 | thread& operator=(thread other) |
| 223 | 159 | { |
| 224 | | swap(x); |
| | 160 | swap(other); |
| 225 | 161 | return *this; |
| 226 | 162 | } |
| 227 | 163 | #else |
| 228 | | thread& operator=(detail::thread_move_t<thread> x) |
| | 164 | thread& operator=(BOOST_RV_REF(thread) other) |
| 229 | 165 | { |
| 230 | | thread new_thread(x); |
| | 166 | thread new_thread(boost::move(other)); |
| 231 | 167 | swap(new_thread); |
| 232 | 168 | return *this; |
| 233 | 169 | } |
| 234 | | #endif |
| 235 | | operator detail::thread_move_t<thread>() |
| | 170 | #endif |
| | 171 | template <class F> |
| | 172 | explicit thread(BOOST_RV_REF(F) f): |
| | 173 | thread_info(make_thread_info(boost::move(f))) |
| 236 | 174 | { |
| 237 | | return move(); |
| | 175 | start_thread(); |
| 238 | 176 | } |
| 239 | | |
| 240 | | detail::thread_move_t<thread> move() |
| | 177 | template <class F> |
| | 178 | explicit thread(F f): |
| | 179 | thread_info(make_thread_info(boost::move(f))) |
| 241 | 180 | { |
| 242 | | detail::thread_move_t<thread> x(*this); |
| 243 | | return x; |
| | 181 | start_thread(); |
| 244 | 182 | } |
| 245 | | |
| 246 | 183 | #endif |
| 247 | 184 | |
| | 185 | thread(BOOST_RV_REF(thread) other) |
| | 186 | { |
| | 187 | thread_info.swap(other.thread_info); |
| | 188 | } |
| | 189 | |
| 248 | 190 | template <class F,class A1> |
| 249 | 191 | thread(F f,A1 a1): |
| 250 | 192 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1))) |
| … |
… |
|
| 355 | 297 | { |
| 356 | 298 | return lhs.swap(rhs); |
| 357 | 299 | } |
| 358 | | |
| 359 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 360 | | inline thread&& move(thread& t) |
| 361 | | { |
| 362 | | return static_cast<thread&&>(t); |
| 363 | | } |
| 364 | | inline thread&& move(thread&& t) |
| 365 | | { |
| 366 | | return static_cast<thread&&>(t); |
| 367 | | } |
| 368 | | #else |
| 369 | | inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> t) |
| 370 | | { |
| 371 | | return t; |
| 372 | | } |
| 373 | | #endif |
| 374 | 300 | |
| 375 | 301 | namespace this_thread |
| 376 | 302 | { |
diff -ur boost_1_48_0/boost/thread/future.hpp boost_1_48_0_patched/boost/thread/future.hpp
|
old
|
new
|
|
| 7 | 7 | #ifndef BOOST_THREAD_FUTURE_HPP |
| 8 | 8 | #define BOOST_THREAD_FUTURE_HPP |
| 9 | 9 | #include <stdexcept> |
| 10 | | #include <boost/thread/detail/move.hpp> |
| | 10 | #include <boost/move/move.hpp> |
| 11 | 11 | #include <boost/thread/thread_time.hpp> |
| 12 | 12 | #include <boost/thread/mutex.hpp> |
| 13 | 13 | #include <boost/thread/condition_variable.hpp> |
| … |
… |
|
| 15 | 15 | #include <boost/shared_ptr.hpp> |
| 16 | 16 | #include <boost/scoped_ptr.hpp> |
| 17 | 17 | #include <boost/type_traits/is_fundamental.hpp> |
| 18 | | #include <boost/type_traits/is_convertible.hpp> |
| | 18 | #include <boost/type_traits/decay.hpp> |
| 19 | 19 | #include <boost/mpl/if.hpp> |
| 20 | 20 | #include <boost/config.hpp> |
| 21 | 21 | #include <boost/throw_exception.hpp> |
| … |
… |
|
| 229 | 229 | typedef typename boost::mpl::if_<boost::is_fundamental<T>,dummy&,T&&>::type rvalue_source_type; |
| 230 | 230 | typedef typename boost::mpl::if_<boost::is_fundamental<T>,T,T&&>::type move_dest_type; |
| 231 | 231 | #else |
| 232 | | typedef T& source_reference_type; |
| 233 | | typedef typename boost::mpl::if_<boost::is_convertible<T&,boost::detail::thread_move_t<T> >,boost::detail::thread_move_t<T>,T const&>::type rvalue_source_type; |
| 234 | | typedef typename boost::mpl::if_<boost::is_convertible<T&,boost::detail::thread_move_t<T> >,boost::detail::thread_move_t<T>,T>::type move_dest_type; |
| | 232 | typedef typename boost::mpl::if_<boost::has_move_emulation_enabled<T>,::boost::rv<T> const&,T&>::type source_reference_type; |
| | 233 | typedef typename boost::mpl::if_<boost::has_move_emulation_enabled<T>,::boost::rv<T>&,T const&>::type rvalue_source_type; |
| | 234 | typedef typename boost::mpl::if_<boost::has_move_emulation_enabled<T>,::boost::rv<T>&,T>::type move_dest_type; |
| 235 | 235 | #endif |
| 236 | 236 | |
| 237 | 237 | static void init(storage_type& storage,source_reference_type t) |
| … |
… |
|
| 322 | 322 | void mark_finished_with_result(rvalue_source_type result_) |
| 323 | 323 | { |
| 324 | 324 | boost::lock_guard<boost::mutex> lock(mutex); |
| 325 | | mark_finished_with_result_internal(result_); |
| | 325 | mark_finished_with_result_internal(static_cast<rvalue_source_type>(result_)); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | | move_dest_type get() |
| | 328 | T& get() |
| 329 | 329 | { |
| 330 | 330 | wait(); |
| 331 | | return static_cast<move_dest_type>(*result); |
| | 331 | return *result; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | future_state::state get_state() |
| … |
… |
|
| 616 | 616 | template <typename R> |
| 617 | 617 | class unique_future |
| 618 | 618 | { |
| 619 | | unique_future(unique_future & rhs);// = delete; |
| 620 | | unique_future& operator=(unique_future& rhs);// = delete; |
| | 619 | BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_future) |
| 621 | 620 | |
| 622 | 621 | typedef boost::shared_ptr<detail::future_object<R> > future_ptr; |
| 623 | 622 | |
| … |
… |
|
| 643 | 642 | ~unique_future() |
| 644 | 643 | {} |
| 645 | 644 | |
| 646 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 647 | | unique_future(unique_future && other) |
| | 645 | unique_future(BOOST_RV_REF(unique_future) other) |
| 648 | 646 | { |
| 649 | 647 | future.swap(other.future); |
| 650 | 648 | } |
| 651 | | unique_future& operator=(unique_future && other) |
| | 649 | unique_future& operator=(BOOST_RV_REF(unique_future) other) |
| 652 | 650 | { |
| 653 | 651 | future=other.future; |
| 654 | 652 | other.future.reset(); |
| 655 | 653 | return *this; |
| 656 | 654 | } |
| 657 | | #else |
| 658 | | unique_future(boost::detail::thread_move_t<unique_future> other): |
| 659 | | future(other->future) |
| 660 | | { |
| 661 | | other->future.reset(); |
| 662 | | } |
| 663 | | |
| 664 | | unique_future& operator=(boost::detail::thread_move_t<unique_future> other) |
| 665 | | { |
| 666 | | future=other->future; |
| 667 | | other->future.reset(); |
| 668 | | return *this; |
| 669 | | } |
| 670 | | |
| 671 | | operator boost::detail::thread_move_t<unique_future>() |
| 672 | | { |
| 673 | | return boost::detail::thread_move_t<unique_future>(*this); |
| 674 | | } |
| 675 | | #endif |
| 676 | 655 | |
| 677 | 656 | void swap(unique_future& other) |
| 678 | 657 | { |
| … |
… |
|
| 687 | 666 | boost::throw_exception(future_uninitialized()); |
| 688 | 667 | } |
| 689 | 668 | |
| 690 | | return future->get(); |
| | 669 | return static_cast<move_dest_type>(future->get()); |
| 691 | 670 | } |
| 692 | 671 | |
| 693 | 672 | // functions to check state, and wait for ready |
| … |
… |
|
| 752 | 731 | // shared_future(const unique_future<R>& other); |
| 753 | 732 | // shared_future& operator=(const unique_future<R>& other); |
| 754 | 733 | |
| | 734 | BOOST_COPYABLE_AND_MOVABLE(shared_future) |
| | 735 | |
| 755 | 736 | friend class detail::future_waiter; |
| 756 | 737 | friend class promise<R>; |
| 757 | 738 | friend class packaged_task<R>; |
| … |
… |
|
| 773 | 754 | ~shared_future() |
| 774 | 755 | {} |
| 775 | 756 | |
| 776 | | shared_future& operator=(shared_future const& other) |
| | 757 | shared_future& operator=(BOOST_COPY_ASSIGN_REF(shared_future) other) |
| 777 | 758 | { |
| 778 | 759 | future=other.future; |
| 779 | 760 | return *this; |
| 780 | 761 | } |
| 781 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 782 | | shared_future(shared_future && other) |
| | 762 | |
| | 763 | shared_future(BOOST_RV_REF(shared_future) other) |
| 783 | 764 | { |
| 784 | 765 | future.swap(other.future); |
| 785 | 766 | } |
| 786 | | shared_future(unique_future<R> && other) |
| | 767 | shared_future(BOOST_RV_REF(unique_future<R>) other) |
| 787 | 768 | { |
| 788 | 769 | future.swap(other.future); |
| 789 | 770 | } |
| 790 | | shared_future& operator=(shared_future && other) |
| | 771 | shared_future& operator=(BOOST_RV_REF(shared_future) other) |
| 791 | 772 | { |
| 792 | 773 | future.swap(other.future); |
| 793 | 774 | other.future.reset(); |
| 794 | 775 | return *this; |
| 795 | 776 | } |
| 796 | | shared_future& operator=(unique_future<R> && other) |
| | 777 | shared_future& operator=(BOOST_RV_REF(unique_future<R>) other) |
| 797 | 778 | { |
| 798 | 779 | future.swap(other.future); |
| 799 | 780 | other.future.reset(); |
| 800 | 781 | return *this; |
| 801 | 782 | } |
| 802 | | #else |
| 803 | | shared_future(boost::detail::thread_move_t<shared_future> other): |
| 804 | | future(other->future) |
| 805 | | { |
| 806 | | other->future.reset(); |
| 807 | | } |
| 808 | | // shared_future(const unique_future<R> &) = delete; |
| 809 | | shared_future(boost::detail::thread_move_t<unique_future<R> > other): |
| 810 | | future(other->future) |
| 811 | | { |
| 812 | | other->future.reset(); |
| 813 | | } |
| 814 | | shared_future& operator=(boost::detail::thread_move_t<shared_future> other) |
| 815 | | { |
| 816 | | future.swap(other->future); |
| 817 | | other->future.reset(); |
| 818 | | return *this; |
| 819 | | } |
| 820 | | shared_future& operator=(boost::detail::thread_move_t<unique_future<R> > other) |
| 821 | | { |
| 822 | | future.swap(other->future); |
| 823 | | other->future.reset(); |
| 824 | | return *this; |
| 825 | | } |
| 826 | | |
| 827 | | operator boost::detail::thread_move_t<shared_future>() |
| 828 | | { |
| 829 | | return boost::detail::thread_move_t<shared_future>(*this); |
| 830 | | } |
| 831 | | |
| 832 | | #endif |
| 833 | 783 | |
| 834 | 784 | void swap(shared_future& other) |
| 835 | 785 | { |
| … |
… |
|
| 837 | 787 | } |
| 838 | 788 | |
| 839 | 789 | // retrieving the value |
| 840 | | R get() |
| | 790 | R const& get() |
| 841 | 791 | { |
| 842 | 792 | if(!future) |
| 843 | 793 | { |
| … |
… |
|
| 907 | 857 | future_ptr future; |
| 908 | 858 | bool future_obtained; |
| 909 | 859 | |
| 910 | | promise(promise & rhs);// = delete; |
| 911 | | promise & operator=(promise & rhs);// = delete; |
| | 860 | BOOST_MOVABLE_BUT_NOT_COPYABLE(promise) |
| 912 | 861 | |
| 913 | 862 | void lazy_init() |
| 914 | 863 | { |
| … |
… |
|
| 940 | 889 | } |
| 941 | 890 | |
| 942 | 891 | // Assignment |
| 943 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 944 | | promise(promise && rhs): |
| | 892 | promise(BOOST_RV_REF(promise) rhs): |
| 945 | 893 | future_obtained(rhs.future_obtained) |
| 946 | 894 | { |
| 947 | 895 | future.swap(rhs.future); |
| 948 | 896 | rhs.future_obtained=false; |
| 949 | 897 | } |
| 950 | | promise & operator=(promise&& rhs) |
| | 898 | promise & operator=(BOOST_RV_REF(promise) rhs) |
| 951 | 899 | { |
| 952 | 900 | future.swap(rhs.future); |
| 953 | 901 | future_obtained=rhs.future_obtained; |
| … |
… |
|
| 955 | 903 | rhs.future_obtained=false; |
| 956 | 904 | return *this; |
| 957 | 905 | } |
| 958 | | #else |
| 959 | | promise(boost::detail::thread_move_t<promise> rhs): |
| 960 | | future(rhs->future),future_obtained(rhs->future_obtained) |
| 961 | | { |
| 962 | | rhs->future.reset(); |
| 963 | | rhs->future_obtained=false; |
| 964 | | } |
| 965 | | promise & operator=(boost::detail::thread_move_t<promise> rhs) |
| 966 | | { |
| 967 | | future=rhs->future; |
| 968 | | future_obtained=rhs->future_obtained; |
| 969 | | rhs->future.reset(); |
| 970 | | rhs->future_obtained=false; |
| 971 | | return *this; |
| 972 | | } |
| 973 | | |
| 974 | | operator boost::detail::thread_move_t<promise>() |
| 975 | | { |
| 976 | | return boost::detail::thread_move_t<promise>(*this); |
| 977 | | } |
| 978 | | #endif |
| 979 | 906 | |
| 980 | 907 | void swap(promise& other) |
| 981 | 908 | { |
| … |
… |
|
| 1046 | 973 | future_ptr future; |
| 1047 | 974 | bool future_obtained; |
| 1048 | 975 | |
| 1049 | | promise(promise & rhs);// = delete; |
| 1050 | | promise & operator=(promise & rhs);// = delete; |
| | 976 | BOOST_MOVABLE_BUT_NOT_COPYABLE(promise) |
| 1051 | 977 | |
| 1052 | 978 | void lazy_init() |
| 1053 | 979 | { |
| … |
… |
|
| 1078 | 1004 | } |
| 1079 | 1005 | |
| 1080 | 1006 | // Assignment |
| 1081 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 1082 | | promise(promise && rhs): |
| | 1007 | promise(BOOST_RV_REF(promise) rhs): |
| 1083 | 1008 | future_obtained(rhs.future_obtained) |
| 1084 | 1009 | { |
| 1085 | 1010 | future.swap(rhs.future); |
| 1086 | 1011 | rhs.future_obtained=false; |
| 1087 | 1012 | } |
| 1088 | | promise & operator=(promise&& rhs) |
| | 1013 | promise & operator=(BOOST_RV_REF(promise) rhs) |
| 1089 | 1014 | { |
| 1090 | 1015 | future.swap(rhs.future); |
| 1091 | 1016 | future_obtained=rhs.future_obtained; |
| … |
… |
|
| 1093 | 1018 | rhs.future_obtained=false; |
| 1094 | 1019 | return *this; |
| 1095 | 1020 | } |
| 1096 | | #else |
| 1097 | | promise(boost::detail::thread_move_t<promise> rhs): |
| 1098 | | future(rhs->future),future_obtained(rhs->future_obtained) |
| 1099 | | { |
| 1100 | | rhs->future.reset(); |
| 1101 | | rhs->future_obtained=false; |
| 1102 | | } |
| 1103 | | promise & operator=(boost::detail::thread_move_t<promise> rhs) |
| 1104 | | { |
| 1105 | | future=rhs->future; |
| 1106 | | future_obtained=rhs->future_obtained; |
| 1107 | | rhs->future.reset(); |
| 1108 | | rhs->future_obtained=false; |
| 1109 | | return *this; |
| 1110 | | } |
| 1111 | | |
| 1112 | | operator boost::detail::thread_move_t<promise>() |
| 1113 | | { |
| 1114 | | return boost::detail::thread_move_t<promise>(*this); |
| 1115 | | } |
| 1116 | | #endif |
| 1117 | 1021 | |
| 1118 | 1022 | void swap(promise& other) |
| 1119 | 1023 | { |
| … |
… |
|
| 1209 | 1113 | struct task_object: |
| 1210 | 1114 | task_base<R> |
| 1211 | 1115 | { |
| | 1116 | struct dummy; |
| 1212 | 1117 | F f; |
| | 1118 | |
| 1213 | 1119 | task_object(F const& f_): |
| 1214 | 1120 | f(f_) |
| 1215 | 1121 | {} |
| 1216 | | task_object(boost::detail::thread_move_t<F> f_): |
| 1217 | | f(f_) |
| | 1122 | |
| | 1123 | task_object(BOOST_RV_REF(F) f_): |
| | 1124 | f(::boost::move(f_)) |
| 1218 | 1125 | {} |
| 1219 | 1126 | |
| 1220 | 1127 | void do_run() |
| … |
… |
|
| 1234 | 1141 | struct task_object<void,F>: |
| 1235 | 1142 | task_base<void> |
| 1236 | 1143 | { |
| | 1144 | struct dummy; |
| 1237 | 1145 | F f; |
| | 1146 | |
| 1238 | 1147 | task_object(F const& f_): |
| 1239 | 1148 | f(f_) |
| 1240 | 1149 | {} |
| 1241 | | task_object(boost::detail::thread_move_t<F> f_): |
| 1242 | | f(f_) |
| | 1150 | |
| | 1151 | task_object(BOOST_RV_REF(F) f_): |
| | 1152 | f(::boost::move(f_)) |
| 1243 | 1153 | {} |
| 1244 | 1154 | |
| 1245 | 1155 | void do_run() |
| … |
… |
|
| 1255 | 1165 | } |
| 1256 | 1166 | } |
| 1257 | 1167 | }; |
| 1258 | | |
| 1259 | 1168 | } |
| 1260 | 1169 | |
| 1261 | 1170 | |
| … |
… |
|
| 1265 | 1174 | boost::shared_ptr<detail::task_base<R> > task; |
| 1266 | 1175 | bool future_obtained; |
| 1267 | 1176 | |
| 1268 | | packaged_task(packaged_task&);// = delete; |
| 1269 | | packaged_task& operator=(packaged_task&);// = delete; |
| 1270 | | |
| | 1177 | BOOST_MOVABLE_BUT_NOT_COPYABLE(packaged_task) |
| | 1178 | struct dummy; |
| 1271 | 1179 | public: |
| 1272 | 1180 | packaged_task(): |
| 1273 | 1181 | future_obtained(false) |
| 1274 | 1182 | {} |
| 1275 | 1183 | |
| 1276 | 1184 | // construction and destruction |
| | 1185 | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 1277 | 1186 | template <class F> |
| 1278 | | explicit packaged_task(F const& f): |
| 1279 | | task(new detail::task_object<R,F>(f)),future_obtained(false) |
| | 1187 | explicit packaged_task(F&& f): |
| | 1188 | task(new detail::task_object<R,typename boost::decay<F>::type>(boost::forward<F>(f))), |
| | 1189 | future_obtained(false) |
| 1280 | 1190 | {} |
| 1281 | | explicit packaged_task(R(*f)()): |
| 1282 | | task(new detail::task_object<R,R(*)()>(f)),future_obtained(false) |
| | 1191 | #else |
| | 1192 | template <class F> |
| | 1193 | explicit packaged_task(F f): |
| | 1194 | task(new detail::task_object<R,F>(boost::move(f))),future_obtained(false) |
| 1283 | 1195 | {} |
| 1284 | 1196 | |
| 1285 | 1197 | template <class F> |
| 1286 | | explicit packaged_task(boost::detail::thread_move_t<F> f): |
| 1287 | | task(new detail::task_object<R,F>(f)),future_obtained(false) |
| | 1198 | explicit packaged_task(BOOST_RV_REF(F) f): |
| | 1199 | task(new detail::task_object<R,F>(boost::move(f))),future_obtained(false) |
| 1288 | 1200 | {} |
| | 1201 | #endif |
| 1289 | 1202 | |
| | 1203 | |
| 1290 | 1204 | // template <class F, class Allocator> |
| 1291 | 1205 | // explicit packaged_task(F const& f, Allocator a); |
| 1292 | 1206 | // template <class F, class Allocator> |
| … |
… |
|
| 1302 | 1216 | } |
| 1303 | 1217 | |
| 1304 | 1218 | // assignment |
| 1305 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 1306 | | packaged_task(packaged_task&& other): |
| | 1219 | packaged_task(BOOST_RV_REF(packaged_task) other): |
| 1307 | 1220 | future_obtained(other.future_obtained) |
| 1308 | 1221 | { |
| 1309 | 1222 | task.swap(other.task); |
| 1310 | 1223 | other.future_obtained=false; |
| 1311 | 1224 | } |
| 1312 | | packaged_task& operator=(packaged_task&& other) |
| | 1225 | packaged_task& operator=(BOOST_RV_REF(packaged_task) other) |
| 1313 | 1226 | { |
| 1314 | | packaged_task temp(static_cast<packaged_task&&>(other)); |
| | 1227 | packaged_task temp(boost::move(other)); |
| 1315 | 1228 | swap(temp); |
| 1316 | 1229 | return *this; |
| 1317 | 1230 | } |
| 1318 | | #else |
| 1319 | | packaged_task(boost::detail::thread_move_t<packaged_task> other): |
| 1320 | | future_obtained(other->future_obtained) |
| 1321 | | { |
| 1322 | | task.swap(other->task); |
| 1323 | | other->future_obtained=false; |
| 1324 | | } |
| 1325 | | packaged_task& operator=(boost::detail::thread_move_t<packaged_task> other) |
| 1326 | | { |
| 1327 | | packaged_task temp(other); |
| 1328 | | swap(temp); |
| 1329 | | return *this; |
| 1330 | | } |
| 1331 | | operator boost::detail::thread_move_t<packaged_task>() |
| 1332 | | { |
| 1333 | | return boost::detail::thread_move_t<packaged_task>(*this); |
| 1334 | | } |
| 1335 | | #endif |
| 1336 | 1231 | |
| 1337 | 1232 | void swap(packaged_task& other) |
| 1338 | 1233 | { |
diff -ur boost_1_48_0/boost/thread/locks.hpp boost_1_48_0_patched/boost/thread/locks.hpp
|
old
|
new
|
|
| 6 | 6 | #define BOOST_THREAD_LOCKS_HPP |
| 7 | 7 | #include <boost/thread/detail/config.hpp> |
| 8 | 8 | #include <boost/thread/exceptions.hpp> |
| 9 | | #include <boost/thread/detail/move.hpp> |
| | 9 | #include <boost/move/move.hpp> |
| 10 | 10 | #include <algorithm> |
| 11 | 11 | #include <iterator> |
| 12 | 12 | #include <boost/thread/thread_time.hpp> |
| … |
… |
|
| 272 | 272 | private: |
| 273 | 273 | Mutex* m; |
| 274 | 274 | bool is_locked; |
| 275 | | unique_lock(unique_lock&); |
| 276 | 275 | explicit unique_lock(upgrade_lock<Mutex>&); |
| 277 | | unique_lock& operator=(unique_lock&); |
| 278 | | unique_lock& operator=(upgrade_lock<Mutex>& other); |
| | 276 | BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_lock); |
| 279 | 277 | public: |
| 280 | 278 | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
| 281 | 279 | unique_lock(const volatile unique_lock&); |
| … |
… |
|
| 311 | 309 | { |
| 312 | 310 | timed_lock(target_time); |
| 313 | 311 | } |
| 314 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 315 | | unique_lock(unique_lock&& other): |
| | 312 | |
| | 313 | unique_lock(BOOST_RV_REF(unique_lock) other): |
| 316 | 314 | m(other.m),is_locked(other.is_locked) |
| 317 | 315 | { |
| 318 | 316 | other.is_locked=false; |
| 319 | 317 | other.m=0; |
| 320 | 318 | } |
| 321 | | explicit unique_lock(upgrade_lock<Mutex>&& other); |
| 322 | | |
| 323 | | unique_lock<Mutex>&& move() |
| 324 | | { |
| 325 | | return static_cast<unique_lock<Mutex>&&>(*this); |
| 326 | | } |
| 327 | | |
| | 319 | explicit unique_lock(BOOST_RV_REF(upgrade_lock<Mutex>) other); |
| 328 | 320 | |
| 329 | | unique_lock& operator=(unique_lock&& other) |
| | 321 | unique_lock& operator=(BOOST_RV_REF(unique_lock) other) |
| 330 | 322 | { |
| 331 | | unique_lock temp(other.move()); |
| | 323 | unique_lock temp(boost::move(other)); |
| 332 | 324 | swap(temp); |
| 333 | 325 | return *this; |
| 334 | 326 | } |
| 335 | 327 | |
| 336 | | unique_lock& operator=(upgrade_lock<Mutex>&& other) |
| | 328 | unique_lock& operator=(BOOST_RV_REF(upgrade_lock<Mutex>) other) |
| 337 | 329 | { |
| 338 | | unique_lock temp(other.move()); |
| | 330 | unique_lock temp(boost::move(other)); |
| 339 | 331 | swap(temp); |
| 340 | 332 | return *this; |
| 341 | 333 | } |
| 342 | | void swap(unique_lock&& other) |
| | 334 | void swap(BOOST_RV_REF(unique_lock) other) |
| 343 | 335 | { |
| 344 | 336 | std::swap(m,other.m); |
| 345 | 337 | std::swap(is_locked,other.is_locked); |
| 346 | 338 | } |
| 347 | | #else |
| 348 | | unique_lock(detail::thread_move_t<unique_lock<Mutex> > other): |
| 349 | | m(other->m),is_locked(other->is_locked) |
| 350 | | { |
| 351 | | other->is_locked=false; |
| 352 | | other->m=0; |
| 353 | | } |
| 354 | | unique_lock(detail::thread_move_t<upgrade_lock<Mutex> > other); |
| 355 | | |
| 356 | | operator detail::thread_move_t<unique_lock<Mutex> >() |
| 357 | | { |
| 358 | | return move(); |
| 359 | | } |
| 360 | | |
| 361 | | detail::thread_move_t<unique_lock<Mutex> > move() |
| 362 | | { |
| 363 | | return detail::thread_move_t<unique_lock<Mutex> >(*this); |
| 364 | | } |
| 365 | 339 | |
| 366 | | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
| 367 | | unique_lock& operator=(unique_lock<Mutex> other) |
| 368 | | { |
| 369 | | swap(other); |
| 370 | | return *this; |
| 371 | | } |
| 372 | | #else |
| 373 | | unique_lock& operator=(detail::thread_move_t<unique_lock<Mutex> > other) |
| 374 | | { |
| 375 | | unique_lock temp(other); |
| 376 | | swap(temp); |
| 377 | | return *this; |
| 378 | | } |
| 379 | | #endif |
| 380 | | |
| 381 | | unique_lock& operator=(detail::thread_move_t<upgrade_lock<Mutex> > other) |
| 382 | | { |
| 383 | | unique_lock temp(other); |
| 384 | | swap(temp); |
| 385 | | return *this; |
| 386 | | } |
| 387 | | void swap(detail::thread_move_t<unique_lock<Mutex> > other) |
| 388 | | { |
| 389 | | std::swap(m,other->m); |
| 390 | | std::swap(is_locked,other->is_locked); |
| 391 | | } |
| 392 | | #endif |
| 393 | 340 | void swap(unique_lock& other) |
| 394 | 341 | { |
| 395 | 342 | std::swap(m,other.m); |
| … |
… |
|
| 479 | 426 | friend class upgrade_lock<Mutex>; |
| 480 | 427 | }; |
| 481 | 428 | |
| 482 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 483 | | template<typename Mutex> |
| 484 | | void swap(unique_lock<Mutex>&& lhs,unique_lock<Mutex>&& rhs) |
| 485 | | { |
| 486 | | lhs.swap(rhs); |
| 487 | | } |
| 488 | 429 | |
| 489 | 430 | template<typename Mutex> |
| 490 | | inline upgrade_lock<Mutex>&& move(upgrade_lock<Mutex>&& ul) |
| | 431 | void swap(BOOST_RV_REF(unique_lock<Mutex>) lhs, BOOST_RV_REF(unique_lock<Mutex>) rhs) |
| 491 | 432 | { |
| 492 | | return static_cast<upgrade_lock<Mutex>&&>(ul); |
| | 433 | lhs.swap(rhs); |
| 493 | 434 | } |
| 494 | 435 | |
| 495 | 436 | template<typename Mutex> |
| 496 | | inline upgrade_lock<Mutex>&& move(upgrade_lock<Mutex>& ul) |
| 497 | | { |
| 498 | | return static_cast<upgrade_lock<Mutex>&&>(ul); |
| 499 | | } |
| 500 | | #endif |
| 501 | | template<typename Mutex> |
| 502 | 437 | void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs) |
| 503 | 438 | { |
| 504 | 439 | lhs.swap(rhs); |
| 505 | 440 | } |
| 506 | 441 | |
| 507 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 508 | | template<typename Mutex> |
| 509 | | inline unique_lock<Mutex>&& move(unique_lock<Mutex>&& ul) |
| 510 | | { |
| 511 | | return static_cast<unique_lock<Mutex>&&>(ul); |
| 512 | | } |
| 513 | | |
| 514 | | template<typename Mutex> |
| 515 | | inline unique_lock<Mutex>&& move(unique_lock<Mutex>& ul) |
| 516 | | { |
| 517 | | return static_cast<unique_lock<Mutex>&&>(ul); |
| 518 | | } |
| 519 | | #endif |
| 520 | | |
| 521 | 442 | template<typename Mutex> |
| 522 | 443 | class shared_lock |
| 523 | 444 | { |
| … |
… |
|
| 525 | 446 | Mutex* m; |
| 526 | 447 | bool is_locked; |
| 527 | 448 | private: |
| 528 | | explicit shared_lock(shared_lock&); |
| 529 | | shared_lock& operator=(shared_lock&); |
| | 449 | BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_lock) |
| 530 | 450 | public: |
| 531 | 451 | shared_lock(): |
| 532 | 452 | m(0),is_locked(false) |
| … |
… |
|
| 554 | 474 | timed_lock(target_time); |
| 555 | 475 | } |
| 556 | 476 | |
| 557 | | shared_lock(detail::thread_move_t<shared_lock<Mutex> > other): |
| | 477 | shared_lock(BOOST_RV_REF(shared_lock<Mutex>) other): |
| 558 | 478 | m(other->m),is_locked(other->is_locked) |
| 559 | 479 | { |
| 560 | 480 | other->is_locked=false; |
| 561 | 481 | other->m=0; |
| 562 | 482 | } |
| 563 | 483 | |
| 564 | | shared_lock(detail::thread_move_t<unique_lock<Mutex> > other): |
| | 484 | shared_lock(BOOST_RV_REF(unique_lock<Mutex>) other): |
| 565 | 485 | m(other->m),is_locked(other->is_locked) |
| 566 | 486 | { |
| 567 | 487 | if(is_locked) |
| … |
… |
|
| 572 | 492 | other->m=0; |
| 573 | 493 | } |
| 574 | 494 | |
| 575 | | shared_lock(detail::thread_move_t<upgrade_lock<Mutex> > other): |
| | 495 | shared_lock(BOOST_RV_REF(upgrade_lock<Mutex>) other): |
| 576 | 496 | m(other->m),is_locked(other->is_locked) |
| 577 | 497 | { |
| 578 | 498 | if(is_locked) |
| … |
… |
|
| 583 | 503 | other->m=0; |
| 584 | 504 | } |
| 585 | 505 | |
| 586 | | operator detail::thread_move_t<shared_lock<Mutex> >() |
| 587 | | { |
| 588 | | return move(); |
| 589 | | } |
| 590 | | |
| 591 | | detail::thread_move_t<shared_lock<Mutex> > move() |
| 592 | | { |
| 593 | | return detail::thread_move_t<shared_lock<Mutex> >(*this); |
| 594 | | } |
| 595 | | |
| 596 | | |
| 597 | | shared_lock& operator=(detail::thread_move_t<shared_lock<Mutex> > other) |
| | 506 | shared_lock& operator=(BOOST_RV_REF(shared_lock<Mutex>) other) |
| 598 | 507 | { |
| 599 | 508 | shared_lock temp(other); |
| 600 | 509 | swap(temp); |
| 601 | 510 | return *this; |
| 602 | 511 | } |
| 603 | 512 | |
| 604 | | shared_lock& operator=(detail::thread_move_t<unique_lock<Mutex> > other) |
| | 513 | shared_lock& operator=(BOOST_RV_REF(unique_lock<Mutex>) other) |
| 605 | 514 | { |
| 606 | 515 | shared_lock temp(other); |
| 607 | 516 | swap(temp); |
| 608 | 517 | return *this; |
| 609 | 518 | } |
| 610 | 519 | |
| 611 | | shared_lock& operator=(detail::thread_move_t<upgrade_lock<Mutex> > other) |
| | 520 | shared_lock& operator=(BOOST_RV_REF(upgrade_lock<Mutex>) other) |
| 612 | 521 | { |
| 613 | 522 | shared_lock temp(other); |
| 614 | 523 | swap(temp); |
| 615 | 524 | return *this; |
| 616 | 525 | } |
| 617 | 526 | |
| 618 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 619 | | void swap(shared_lock&& other) |
| | 527 | void swap(BOOST_RV_REF(shared_lock) other) |
| 620 | 528 | { |
| 621 | 529 | std::swap(m,other.m); |
| 622 | 530 | std::swap(is_locked,other.is_locked); |
| 623 | 531 | } |
| 624 | | #else |
| 625 | | void swap(boost::detail::thread_move_t<shared_lock<Mutex> > other) |
| 626 | | { |
| 627 | | std::swap(m,other->m); |
| 628 | | std::swap(is_locked,other->is_locked); |
| 629 | | } |
| 630 | | #endif |
| | 532 | |
| 631 | 533 | void swap(shared_lock& other) |
| 632 | 534 | { |
| 633 | 535 | std::swap(m,other.m); |
| … |
… |
|
| 709 | 611 | |
| 710 | 612 | }; |
| 711 | 613 | |
| 712 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 713 | | template<typename Mutex> |
| 714 | | void swap(shared_lock<Mutex>&& lhs,shared_lock<Mutex>&& rhs) |
| 715 | | { |
| 716 | | lhs.swap(rhs); |
| 717 | | } |
| 718 | | #else |
| 719 | 614 | template<typename Mutex> |
| 720 | | void swap(shared_lock<Mutex>& lhs,shared_lock<Mutex>& rhs) |
| | 615 | void swap(BOOST_RV_REF(shared_lock<Mutex>) lhs,BOOST_RV_REF(shared_lock<Mutex>) rhs) |
| 721 | 616 | { |
| 722 | 617 | lhs.swap(rhs); |
| 723 | 618 | } |
| 724 | | #endif |
| 725 | 619 | |
| 726 | 620 | template<typename Mutex> |
| 727 | 621 | class upgrade_lock |
| … |
… |
|
| 730 | 624 | Mutex* m; |
| 731 | 625 | bool is_locked; |
| 732 | 626 | private: |
| 733 | | explicit upgrade_lock(upgrade_lock&); |
| 734 | | upgrade_lock& operator=(upgrade_lock&); |
| | 627 | BOOST_MOVABLE_BUT_NOT_COPYABLE(upgrade_lock) |
| 735 | 628 | public: |
| 736 | 629 | upgrade_lock(): |
| 737 | 630 | m(0),is_locked(false) |
| … |
… |
|
| 753 | 646 | { |
| 754 | 647 | try_lock(); |
| 755 | 648 | } |
| 756 | | #ifdef BOOST_HAS_RVALUE_REFS |
| 757 | | upgrade_lock(upgrade_lock<Mutex>&& other): |
| | 649 | |
| | 650 | upgrade_lock(BOOST_RV_REF(upgrade_lock) other): |
| 758 | 651 | m(other.m),is_locked(other.is_locked) |
| 759 | 652 | { |
| 760 | 653 | other.is_locked=false; |
| 761 | 654 | other.m=0; |
| 762 | 655 | } |
| 763 | 656 | |
| 764 | | upgrade_lock(unique_lock<Mutex>&& other): |
| | 657 | upgrade_lock(BOOST_RV_REF(unique_lock<Mutex>) other): |
| 765 | 658 | m(other.m),is_locked(other.is_locked) |
| 766 | 659 | { |
| 767 | 660 | if(is_locked) |
| … |
… |
|
| 772 | 665 | other.m=0; |
| 773 | 666 | } |
| 774 | 667 | |
| 775 | | upgrade_lock& operator=(upgrade_lock<Mutex>&& other) |
| | 668 | upgrade_lock& operator=(BOOST_RV_REF(upgrade_lock) other) |
| 776 | 669 | { |
| 777 | | upgrade_lock temp(static_cast<upgrade_lock<Mutex>&&>(other)); |
| | 670 | upgrade_lock temp(boost::move(other)); |
| 778 | 671 | swap(temp); |
| 779 | 672 | return *this; |
| 780 | 673 | } |
| 781 | 674 | |
| 782 | | upgrade_lock& operator=(unique_lock<Mutex>&& other) |
| | 675 | upgrade_lock& operator=(BOOST_RV_REF(unique_lock<Mutex>) other) |
| 783 | 676 | { |
| 784 | | upgrade_lock temp(static_cast<unique_lock<Mutex>&&>(other)); |
| | 677 | upgrade_lock temp(boost::move(other)); |
| 785 | 678 | swap(temp); |
| 786 | 679 | return *this; |
| 787 | 680 | } |
| 788 | | #else |
| 789 | | upgrade_lock(detail::thread_move_t<upgrade_lock<Mutex> > other): |
| 790 | | m(other->m),is_locked(other->is_locked) |
| 791 | | { |
| 792 | | other->is_locked=false; |
| 793 | | other->m=0; |
| 794 | | } |
| 795 | | |
| 796 | | upgrade_lock(detail::thread_move_t<unique_lock<Mutex> > other): |
| 797 | | m(other->m),is_locked(other->is_locked) |
| 798 | | { |
| 799 | | if(is_locked) |
| 800 | | { |
| 801 | | m->unlock_and_lock_upgrade(); |
| 802 | | } |
| 803 | | other->is_locked=false; |
| 804 | | other->m=0; |
| 805 | | } |
| 806 | | |
| 807 | | operator detail::thread_move_t<upgrade_lock<Mutex> >() |
| 808 | | { |
| 809 | | return move(); |
| 810 | | } |
| 811 | | |
| 812 | | detail::thread_move_t<upgrade_lock<Mutex> > move() |
| 813 | | { |
| 814 | | return detail::thread_move_t<upgrade_lock<Mutex> >(*this); |
| 815 | | } |
| 816 | | |
| 817 | | |
| 818 | | upgrade_lock& operator=(detail::thread_move_t<upgrade_lock<Mutex> > other) |
| 819 | | { |
| 820 | | upgrade_lock temp(other); |
| 821 | | swap(temp); |
| 822 | | return *this; |
| 823 | | } |
| 824 | | |
| 825 | | upgrade_lock& operator=(detail::thread_move_t<unique_lock<Mutex> > other) |
| 826 | | { |
| 827 | | upgrade_lock temp(other); |
| 828 | | swap(temp); |
| 829 | | return *this; |
| 830 | | } |
| 831 | | #endif |
| 832 | 681 | |
| 833 | 682 | void swap(upgrade_lock& other) |
| 834 | 683 | { |
| … |
… |
|
| 888 | 737 | friend class unique_lock<Mutex>; |
| 889 | 738 | }; |
| 890 | 739 | |
| 891 | | |
| 892 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 893 | 740 | template<typename Mutex> |
| 894 | | unique_lock<Mutex>::unique_lock(upgrade_lock<Mutex>&& other): |
| | 741 | unique_lock<Mutex>::unique_lock(BOOST_RV_REF(upgrade_lock<Mutex>) other): |
| 895 | 742 | m(other.m),is_locked(other.is_locked) |
| 896 | 743 | { |
| 897 | 744 | other.is_locked=false; |
| … |
… |
|
| 900 | 747 | m->unlock_upgrade_and_lock(); |
| 901 | 748 | } |
| 902 | 749 | } |
| 903 | | #else |
| 904 | | template<typename Mutex> |
| 905 | | unique_lock<Mutex>::unique_lock(detail::thread_move_t<upgrade_lock<Mutex> > other): |
| 906 | | m(other->m),is_locked(other->is_locked) |
| 907 | | { |
| 908 | | other->is_locked=false; |
| 909 | | if(is_locked) |
| 910 | | { |
| 911 | | m->unlock_upgrade_and_lock(); |
| 912 | | } |
| 913 | | } |
| 914 | | #endif |
| | 750 | |
| 915 | 751 | template <class Mutex> |
| 916 | 752 | class upgrade_to_unique_lock |
| 917 | 753 | { |
| … |
… |
|
| 919 | 755 | upgrade_lock<Mutex>* source; |
| 920 | 756 | unique_lock<Mutex> exclusive; |
| 921 | 757 | |
| 922 | | explicit upgrade_to_unique_lock(upgrade_to_unique_lock&); |
| 923 | | upgrade_to_unique_lock& operator=(upgrade_to_unique_lock&); |
| | 758 | BOOST_MOVABLE_BUT_NOT_COPYABLE(upgrade_to_unique_lock) |
| 924 | 759 | public: |
| 925 | 760 | explicit upgrade_to_unique_lock(upgrade_lock<Mutex>& m_): |
| 926 | | source(&m_),exclusive(move(*source)) |
| | 761 | source(&m_),exclusive(boost::move(*source)) |
| 927 | 762 | {} |
| 928 | 763 | ~upgrade_to_unique_lock() |
| 929 | 764 | { |
| 930 | 765 | if(source) |
| 931 | 766 | { |
| 932 | | *source=move(exclusive); |
| | 767 | *source=boost::move(exclusive); |
| 933 | 768 | } |
| 934 | 769 | } |
| 935 | 770 | |
| 936 | | #ifdef BOOST_HAS_RVALUE_REFS |
| 937 | | upgrade_to_unique_lock(upgrade_to_unique_lock<Mutex>&& other): |
| 938 | | source(other.source),exclusive(move(other.exclusive)) |
| | 771 | upgrade_to_unique_lock(BOOST_RV_REF(upgrade_to_unique_lock<Mutex>) other): |
| | 772 | source(other.source),exclusive(boost::move(other.exclusive)) |
| 939 | 773 | { |
| 940 | 774 | other.source=0; |
| 941 | 775 | } |
| 942 | 776 | |
| 943 | | upgrade_to_unique_lock& operator=(upgrade_to_unique_lock<Mutex>&& other) |
| 944 | | { |
| 945 | | upgrade_to_unique_lock temp(other); |
| 946 | | swap(temp); |
| 947 | | return *this; |
| 948 | | } |
| 949 | | #else |
| 950 | | upgrade_to_unique_lock(detail::thread_move_t<upgrade_to_unique_lock<Mutex> > other): |
| 951 | | source(other->source),exclusive(move(other->exclusive)) |
| 952 | | { |
| 953 | | other->source=0; |
| 954 | | } |
| 955 | | |
| 956 | | upgrade_to_unique_lock& operator=(detail::thread_move_t<upgrade_to_unique_lock<Mutex> > other) |
| | 777 | upgrade_to_unique_lock& operator=(BOOST_RV_REF(upgrade_to_unique_lock<Mutex>) other) |
| 957 | 778 | { |
| 958 | 779 | upgrade_to_unique_lock temp(other); |
| 959 | 780 | swap(temp); |
| 960 | 781 | return *this; |
| 961 | 782 | } |
| 962 | | #endif |
| | 783 | |
| 963 | 784 | void swap(upgrade_to_unique_lock& other) |
| 964 | 785 | { |
| 965 | 786 | std::swap(source,other.source); |
| … |
… |
|
| 986 | 807 | class try_lock_wrapper: |
| 987 | 808 | private unique_lock<Mutex> |
| 988 | 809 | { |
| | 810 | BOOST_MOVABLE_BUT_NOT_COPYABLE(try_lock_wrapper) |
| 989 | 811 | typedef unique_lock<Mutex> base; |
| 990 | 812 | public: |
| 991 | 813 | try_lock_wrapper() |
| … |
… |
|
| 1004 | 826 | try_lock_wrapper(Mutex& m_,try_to_lock_t): |
| 1005 | 827 | base(m_,try_to_lock) |
| 1006 | 828 | {} |
| 1007 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 1008 | | try_lock_wrapper(try_lock_wrapper&& other): |
| 1009 | | base(other.move()) |
| 1010 | | {} |
| 1011 | 829 | |
| 1012 | | try_lock_wrapper&& move() |
| 1013 | | { |
| 1014 | | return static_cast<try_lock_wrapper&&>(*this); |
| 1015 | | } |
| 1016 | | |
| 1017 | | try_lock_wrapper& operator=(try_lock_wrapper<Mutex>&& other) |
| | 830 | try_lock_wrapper(BOOST_RV_REF(try_lock_wrapper) other): |
| | 831 | base(boost::move(static_cast<base&>(other))) |
| | 832 | {} |
| | 833 | |
| | 834 | try_lock_wrapper& operator=(BOOST_RV_REF(try_lock_wrapper<Mutex>) other) |
| 1018 | 835 | { |
| 1019 | | try_lock_wrapper temp(other.move()); |
| | 836 | try_lock_wrapper temp(boost::move(other)); |
| 1020 | 837 | swap(temp); |
| 1021 | 838 | return *this; |
| 1022 | 839 | } |
| 1023 | 840 | |
| 1024 | | void swap(try_lock_wrapper&& other) |
| | 841 | void swap(BOOST_RV_REF(try_lock_wrapper) other) |
| 1025 | 842 | { |
| 1026 | 843 | base::swap(other); |
| 1027 | 844 | } |
| 1028 | | #else |
| 1029 | | try_lock_wrapper(detail::thread_move_t<try_lock_wrapper<Mutex> > other): |
| 1030 | | base(detail::thread_move_t<base>(*other)) |
| 1031 | | {} |
| 1032 | | |
| 1033 | | operator detail::thread_move_t<try_lock_wrapper<Mutex> >() |
| 1034 | | { |
| 1035 | | return move(); |
| 1036 | | } |
| 1037 | | |
| 1038 | | detail::thread_move_t<try_lock_wrapper<Mutex> > move() |
| 1039 | | { |
| 1040 | | return detail::thread_move_t<try_lock_wrapper<Mutex> >(*this); |
| 1041 | | } |
| 1042 | | |
| 1043 | | try_lock_wrapper& operator=(detail::thread_move_t<try_lock_wrapper<Mutex> > other) |
| 1044 | | { |
| 1045 | | try_lock_wrapper temp(other); |
| 1046 | | swap(temp); |
| 1047 | | return *this; |
| 1048 | | } |
| 1049 | 845 | |
| 1050 | | void swap(detail::thread_move_t<try_lock_wrapper<Mutex> > other) |
| 1051 | | { |
| 1052 | | base::swap(*other); |
| 1053 | | } |
| 1054 | | #endif |
| 1055 | 846 | void swap(try_lock_wrapper& other) |
| 1056 | 847 | { |
| 1057 | 848 | base::swap(other); |
| … |
… |
|
| 1092 | 883 | } |
| 1093 | 884 | }; |
| 1094 | 885 | |
| 1095 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
| 1096 | 886 | template<typename Mutex> |
| 1097 | | void swap(try_lock_wrapper<Mutex>&& lhs,try_lock_wrapper<Mutex>&& rhs) |
| | 887 | void swap(BOOST_RV_REF(try_lock_wrapper<Mutex>) lhs,BOOST_RV_REF(try_lock_wrapper<Mutex>) rhs) |
| 1098 | 888 | { |
| 1099 | 889 | lhs.swap(rhs); |
| 1100 | 890 | } |
| 1101 | | #else |
| 1102 | | template<typename Mutex> |
| 1103 | | void swap(try_lock_wrapper<Mutex>& lhs,try_lock_wrapper<Mutex>& rhs) |
| 1104 | | { |
| 1105 | | lhs.swap(rhs); |
| 1106 | | } |
| 1107 | | #endif |
| 1108 | 891 | |
| 1109 | 892 | template<typename MutexType1,typename MutexType2> |
| 1110 | 893 | unsigned try_lock_internal(MutexType1& m1,MutexType2& m2) |