diff -ur boost_1_48_0/boost/move/move.hpp boost_1_48_0_patched/boost/move/move.hpp
old
|
new
|
|
375 | 375 | { return *static_cast< ::boost::rv<TYPE>* >(this); }\ |
376 | 376 | operator const ::boost::rv<TYPE>&() const \ |
377 | 377 | { return *static_cast<const ::boost::rv<TYPE>* >(this); }\ |
| 378 | ::boost::rv<TYPE>& move()\ |
| 379 | { return static_cast< ::boost::rv<TYPE>& >(*this); }\ |
| 380 | ::boost::rv<TYPE> const& copy() const\ |
| 381 | { return static_cast< ::boost::rv<TYPE> const& >(*this); }\ |
378 | 382 | private:\ |
379 | 383 | // |
380 | 384 | |
… |
… |
|
393 | 397 | { return *static_cast< ::boost::rv<TYPE>* >(this); }\ |
394 | 398 | operator const ::boost::rv<TYPE>&() const \ |
395 | 399 | { return *static_cast<const ::boost::rv<TYPE>* >(this); }\ |
| 400 | ::boost::rv<TYPE>& move()\ |
| 401 | { return static_cast< ::boost::rv<TYPE>& >(*this); }\ |
| 402 | ::boost::rv<TYPE> const& copy() const\ |
| 403 | { return static_cast< ::boost::rv<TYPE> const& >(*this); }\ |
396 | 404 | private:\ |
397 | 405 | // |
398 | 406 | |
… |
… |
|
402 | 410 | { return *static_cast< ::boost::rv<TYPE>* >(this); }\ |
403 | 411 | operator const ::boost::rv<TYPE>&() const \ |
404 | 412 | { return *static_cast<const ::boost::rv<TYPE>* >(this); }\ |
| 413 | ::boost::rv<TYPE>& move()\ |
| 414 | { return static_cast< ::boost::rv<TYPE>& >(*this); }\ |
| 415 | ::boost::rv<TYPE> const& copy() const\ |
| 416 | { return static_cast< ::boost::rv<TYPE> const& >(*this); }\ |
405 | 417 | private:\ |
406 | 418 | // |
407 | 419 | |
… |
… |
|
518 | 530 | #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ |
519 | 531 | public:\ |
520 | 532 | typedef int boost_move_emulation_t;\ |
| 533 | TYPE&& move()\ |
| 534 | { return static_cast< TYPE&& >(*this); }\ |
| 535 | TYPE const& copy() const\ |
| 536 | { return static_cast< TYPE const& >(*this); }\ |
521 | 537 | private:\ |
522 | 538 | TYPE(const TYPE &);\ |
523 | 539 | TYPE& operator=(const TYPE &);\ |
… |
… |
|
527 | 543 | //! The user will need to write a move constructor/assignment and a copy assignment |
528 | 544 | //! as explained in the documentation to fully write a copyable and movable class. |
529 | 545 | #define BOOST_COPYABLE_AND_MOVABLE(TYPE)\ |
| 546 | public:\ |
| 547 | TYPE&& move()\ |
| 548 | { return static_cast< TYPE&& >(*this); }\ |
| 549 | TYPE const& copy() const\ |
| 550 | { return static_cast< TYPE const& >(*this); }\ |
| 551 | private:\ |
530 | 552 | // |
531 | 553 | |
532 | 554 | #define BOOST_COPYABLE_AND_MOVABLE_ALT(TYPE)\ |
| 555 | public:\ |
| 556 | TYPE&& move()\ |
| 557 | { return static_cast< TYPE&& >(*this); }\ |
| 558 | TYPE const& copy() const\ |
| 559 | { return static_cast< TYPE const& >(*this); }\ |
| 560 | private:\ |
533 | 561 | // |
534 | 562 | |
535 | 563 | //!This macro is used to achieve portable syntax in move |
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> |
… |
… |
|
23 | 23 | #include <stdlib.h> |
24 | 24 | #include <memory> |
25 | 25 | #include <boost/utility/enable_if.hpp> |
| 26 | #include <boost/type_traits/is_convertible.hpp> |
26 | 27 | #include <boost/type_traits/remove_reference.hpp> |
| 28 | #include <boost/type_traits/is_lvalue_reference.hpp> |
| 29 | #include <boost/mpl/if.hpp> |
27 | 30 | |
28 | 31 | #include <boost/config/abi_prefix.hpp> |
29 | 32 | |
… |
… |
|
41 | 44 | public detail::thread_data_base |
42 | 45 | { |
43 | 46 | public: |
44 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
45 | | thread_data(F&& f_): |
46 | | f(static_cast<F&&>(f_)) |
47 | | {} |
48 | | thread_data(F& f_): |
49 | | f(f_) |
| 47 | thread_data(BOOST_RV_REF(F) f_): |
| 48 | f(boost::move(f_)) |
50 | 49 | {} |
51 | | #else |
52 | | thread_data(F f_): |
| 50 | thread_data(F const& f_): |
53 | 51 | f(f_) |
54 | 52 | {} |
55 | | thread_data(detail::thread_move_t<F> f_): |
| 53 | void run() |
| 54 | { |
| 55 | f(); |
| 56 | } |
| 57 | private: |
| 58 | F f; |
| 59 | |
| 60 | void operator=(thread_data&); |
| 61 | thread_data(thread_data&); |
| 62 | }; |
| 63 | |
| 64 | template<typename R> |
| 65 | class thread_data<R()>: |
| 66 | public detail::thread_data_base |
| 67 | { |
| 68 | public: |
| 69 | thread_data(R f_()): |
56 | 70 | f(f_) |
57 | 71 | {} |
58 | | #endif |
59 | 72 | void run() |
60 | 73 | { |
61 | 74 | f(); |
62 | 75 | } |
63 | 76 | private: |
64 | | F f; |
| 77 | R (*f)(); |
65 | 78 | |
66 | 79 | void operator=(thread_data&); |
67 | 80 | thread_data(thread_data&); |
… |
… |
|
110 | 123 | class BOOST_THREAD_DECL thread |
111 | 124 | { |
112 | 125 | private: |
113 | | thread(thread&); |
114 | | thread& operator=(thread&); |
115 | | |
| 126 | BOOST_MOVABLE_BUT_NOT_COPYABLE(thread) |
116 | 127 | void release_handle(); |
117 | 128 | |
118 | 129 | detail::thread_data_ptr thread_info; |
… |
… |
|
123 | 134 | |
124 | 135 | detail::thread_data_ptr get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const; |
125 | 136 | |
126 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
127 | 137 | template<typename F> |
128 | | static inline detail::thread_data_ptr make_thread_info(F&& f) |
| 138 | static inline detail::thread_data_ptr make_thread_info(BOOST_RV_REF(F) f) |
129 | 139 | { |
130 | | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >(static_cast<F&&>(f))); |
| 140 | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<typename boost::remove_reference<F>::type> >(boost::move(f))); |
131 | 141 | } |
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))); |
135 | | } |
136 | | #else |
137 | 142 | template<typename F> |
138 | | static inline detail::thread_data_ptr make_thread_info(F f) |
139 | | { |
140 | | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<F> >(f)); |
141 | | } |
142 | | template<typename F> |
143 | | static inline detail::thread_data_ptr make_thread_info(boost::detail::thread_move_t<F> f) |
| 143 | static inline detail::thread_data_ptr make_thread_info(F const& f) |
144 | 144 | { |
145 | 145 | return detail::thread_data_ptr(detail::heap_new<detail::thread_data<F> >(f)); |
146 | 146 | } |
147 | 147 | |
148 | | #endif |
149 | 148 | struct dummy; |
150 | 149 | public: |
151 | 150 | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
… |
… |
|
155 | 154 | ~thread(); |
156 | 155 | |
157 | 156 | #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 | 157 | thread& operator=(thread&& other) |
180 | 158 | { |
181 | 159 | thread_info=other.thread_info; |
182 | 160 | other.thread_info.reset(); |
183 | 161 | return *this; |
184 | 162 | } |
185 | | |
186 | | thread&& move() |
187 | | { |
188 | | return static_cast<thread&&>(*this); |
189 | | } |
190 | | |
191 | | #else |
192 | | #ifdef BOOST_NO_SFINAE |
193 | 163 | template <class F> |
194 | | explicit thread(F f): |
195 | | thread_info(make_thread_info(f)) |
| 164 | explicit thread(F&& f): |
| 165 | thread_info(make_thread_info(static_cast<typename boost::mpl::if_<boost::is_lvalue_reference<F>, typename boost::remove_reference<F>::type const&, F&&>::type>(f))) |
196 | 166 | { |
197 | 167 | start_thread(); |
198 | 168 | } |
199 | 169 | #else |
200 | 170 | 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): |
| 171 | explicit thread(F const& f,typename disable_if<boost::is_convertible<F&,rv<F>&>, dummy* >::type=0): |
210 | 172 | thread_info(make_thread_info(f)) |
211 | 173 | { |
212 | 174 | start_thread(); |
213 | 175 | } |
214 | 176 | |
215 | | thread(detail::thread_move_t<thread> x) |
216 | | { |
217 | | thread_info=x->thread_info; |
218 | | x->thread_info.reset(); |
219 | | } |
220 | | |
221 | 177 | #if BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) |
222 | | thread& operator=(thread x) |
| 178 | thread& operator=(thread other) |
223 | 179 | { |
224 | | swap(x); |
| 180 | swap(other); |
225 | 181 | return *this; |
226 | 182 | } |
227 | 183 | #else |
228 | | thread& operator=(detail::thread_move_t<thread> x) |
| 184 | thread& operator=(BOOST_RV_REF(thread) other) |
229 | 185 | { |
230 | | thread new_thread(x); |
| 186 | thread new_thread(boost::move(other)); |
231 | 187 | swap(new_thread); |
232 | 188 | return *this; |
233 | 189 | } |
234 | | #endif |
235 | | operator detail::thread_move_t<thread>() |
| 190 | #endif |
| 191 | template <class F> |
| 192 | explicit thread(BOOST_RV_REF(F) f): |
| 193 | thread_info(make_thread_info(boost::move(f))) |
236 | 194 | { |
237 | | return move(); |
| 195 | start_thread(); |
238 | 196 | } |
239 | 197 | |
240 | | detail::thread_move_t<thread> move() |
| 198 | template <class F> |
| 199 | explicit thread(F& f): |
| 200 | thread_info(make_thread_info(f)) |
241 | 201 | { |
242 | | detail::thread_move_t<thread> x(*this); |
243 | | return x; |
| 202 | start_thread(); |
244 | 203 | } |
245 | | |
246 | 204 | #endif |
247 | 205 | |
| 206 | template <class F> |
| 207 | explicit thread(BOOST_CATCH_CONST_RLVALUE(F) f): |
| 208 | thread_info(make_thread_info<F>(f)) |
| 209 | { |
| 210 | start_thread(); |
| 211 | } |
| 212 | |
| 213 | thread(BOOST_RV_REF(thread) other) |
| 214 | { |
| 215 | thread_info.swap(other.thread_info); |
| 216 | } |
| 217 | |
248 | 218 | template <class F,class A1> |
249 | 219 | thread(F f,A1 a1): |
250 | 220 | thread_info(make_thread_info(boost::bind(boost::type<void>(),f,a1))) |
… |
… |
|
355 | 325 | { |
356 | 326 | return lhs.swap(rhs); |
357 | 327 | } |
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 | 328 | |
375 | 329 | namespace this_thread |
376 | 330 | { |
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> |
… |
… |
|
16 | 16 | #include <boost/scoped_ptr.hpp> |
17 | 17 | #include <boost/type_traits/is_fundamental.hpp> |
18 | 18 | #include <boost/type_traits/is_convertible.hpp> |
| 19 | #include <boost/type_traits/is_lvalue_reference.hpp> |
| 20 | #include <boost/type_traits/remove_reference.hpp> |
19 | 21 | #include <boost/mpl/if.hpp> |
20 | 22 | #include <boost/config.hpp> |
21 | 23 | #include <boost/throw_exception.hpp> |
… |
… |
|
229 | 231 | typedef typename boost::mpl::if_<boost::is_fundamental<T>,dummy&,T&&>::type rvalue_source_type; |
230 | 232 | typedef typename boost::mpl::if_<boost::is_fundamental<T>,T,T&&>::type move_dest_type; |
231 | 233 | #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; |
| 234 | typedef boost::is_convertible<T&, ::boost::rv<T>& > T_supports_move_emulation; |
| 235 | typedef typename boost::mpl::if_<T_supports_move_emulation,::boost::rv<T> const&,T&>::type source_reference_type; |
| 236 | typedef typename boost::mpl::if_<T_supports_move_emulation,::boost::rv<T>&,T const&>::type rvalue_source_type; |
| 237 | typedef typename boost::mpl::if_<T_supports_move_emulation,::boost::rv<T>&,T>::type move_dest_type; |
235 | 238 | #endif |
236 | 239 | |
237 | 240 | static void init(storage_type& storage,source_reference_type t) |
… |
… |
|
322 | 325 | void mark_finished_with_result(rvalue_source_type result_) |
323 | 326 | { |
324 | 327 | boost::lock_guard<boost::mutex> lock(mutex); |
325 | | mark_finished_with_result_internal(result_); |
| 328 | mark_finished_with_result_internal(static_cast<rvalue_source_type>(result_)); |
326 | 329 | } |
327 | 330 | |
328 | | move_dest_type get() |
| 331 | T& get() |
329 | 332 | { |
330 | 333 | wait(); |
331 | | return static_cast<move_dest_type>(*result); |
| 334 | return *result; |
332 | 335 | } |
333 | 336 | |
334 | 337 | future_state::state get_state() |
… |
… |
|
616 | 619 | template <typename R> |
617 | 620 | class unique_future |
618 | 621 | { |
619 | | unique_future(unique_future & rhs);// = delete; |
620 | | unique_future& operator=(unique_future& rhs);// = delete; |
| 622 | BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_future) |
621 | 623 | |
622 | 624 | typedef boost::shared_ptr<detail::future_object<R> > future_ptr; |
623 | 625 | |
… |
… |
|
643 | 645 | ~unique_future() |
644 | 646 | {} |
645 | 647 | |
646 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
647 | | unique_future(unique_future && other) |
| 648 | unique_future(BOOST_RV_REF(unique_future) other) |
648 | 649 | { |
649 | 650 | future.swap(other.future); |
650 | 651 | } |
651 | | unique_future& operator=(unique_future && other) |
| 652 | unique_future& operator=(BOOST_RV_REF(unique_future) other) |
652 | 653 | { |
653 | 654 | future=other.future; |
654 | 655 | other.future.reset(); |
655 | 656 | return *this; |
656 | 657 | } |
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 | 658 | |
677 | 659 | void swap(unique_future& other) |
678 | 660 | { |
… |
… |
|
687 | 669 | boost::throw_exception(future_uninitialized()); |
688 | 670 | } |
689 | 671 | |
690 | | return future->get(); |
| 672 | return static_cast<move_dest_type>(future->get()); |
691 | 673 | } |
692 | 674 | |
693 | 675 | // functions to check state, and wait for ready |
… |
… |
|
752 | 734 | // shared_future(const unique_future<R>& other); |
753 | 735 | // shared_future& operator=(const unique_future<R>& other); |
754 | 736 | |
| 737 | BOOST_COPYABLE_AND_MOVABLE(shared_future) |
| 738 | |
755 | 739 | friend class detail::future_waiter; |
756 | 740 | friend class promise<R>; |
757 | 741 | friend class packaged_task<R>; |
… |
… |
|
773 | 757 | ~shared_future() |
774 | 758 | {} |
775 | 759 | |
776 | | shared_future& operator=(shared_future const& other) |
| 760 | shared_future& operator=(BOOST_COPY_ASSIGN_REF(shared_future) other) |
777 | 761 | { |
778 | 762 | future=other.future; |
779 | 763 | return *this; |
780 | 764 | } |
781 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
782 | | shared_future(shared_future && other) |
| 765 | |
| 766 | shared_future(BOOST_RV_REF(shared_future) other) |
783 | 767 | { |
784 | 768 | future.swap(other.future); |
785 | 769 | } |
786 | | shared_future(unique_future<R> && other) |
| 770 | shared_future(BOOST_RV_REF(unique_future<R>) other) |
787 | 771 | { |
788 | 772 | future.swap(other.future); |
789 | 773 | } |
790 | | shared_future& operator=(shared_future && other) |
| 774 | shared_future& operator=(BOOST_RV_REF(shared_future) other) |
791 | 775 | { |
792 | 776 | future.swap(other.future); |
793 | 777 | other.future.reset(); |
794 | 778 | return *this; |
795 | 779 | } |
796 | | shared_future& operator=(unique_future<R> && other) |
| 780 | shared_future& operator=(BOOST_RV_REF(unique_future<R>) other) |
797 | 781 | { |
798 | 782 | future.swap(other.future); |
799 | 783 | other.future.reset(); |
800 | 784 | return *this; |
801 | 785 | } |
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 | 786 | |
834 | 787 | void swap(shared_future& other) |
835 | 788 | { |
… |
… |
|
837 | 790 | } |
838 | 791 | |
839 | 792 | // retrieving the value |
840 | | R get() |
| 793 | R const& get() |
841 | 794 | { |
842 | 795 | if(!future) |
843 | 796 | { |
… |
… |
|
907 | 860 | future_ptr future; |
908 | 861 | bool future_obtained; |
909 | 862 | |
910 | | promise(promise & rhs);// = delete; |
911 | | promise & operator=(promise & rhs);// = delete; |
| 863 | BOOST_MOVABLE_BUT_NOT_COPYABLE(promise) |
912 | 864 | |
913 | 865 | void lazy_init() |
914 | 866 | { |
… |
… |
|
940 | 892 | } |
941 | 893 | |
942 | 894 | // Assignment |
943 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
944 | | promise(promise && rhs): |
| 895 | promise(BOOST_RV_REF(promise) rhs): |
945 | 896 | future_obtained(rhs.future_obtained) |
946 | 897 | { |
947 | 898 | future.swap(rhs.future); |
948 | 899 | rhs.future_obtained=false; |
949 | 900 | } |
950 | | promise & operator=(promise&& rhs) |
| 901 | promise & operator=(BOOST_RV_REF(promise) rhs) |
951 | 902 | { |
952 | 903 | future.swap(rhs.future); |
953 | 904 | future_obtained=rhs.future_obtained; |
… |
… |
|
955 | 906 | rhs.future_obtained=false; |
956 | 907 | return *this; |
957 | 908 | } |
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 | 909 | |
980 | 910 | void swap(promise& other) |
981 | 911 | { |
… |
… |
|
1046 | 976 | future_ptr future; |
1047 | 977 | bool future_obtained; |
1048 | 978 | |
1049 | | promise(promise & rhs);// = delete; |
1050 | | promise & operator=(promise & rhs);// = delete; |
| 979 | BOOST_MOVABLE_BUT_NOT_COPYABLE(promise) |
1051 | 980 | |
1052 | 981 | void lazy_init() |
1053 | 982 | { |
… |
… |
|
1078 | 1007 | } |
1079 | 1008 | |
1080 | 1009 | // Assignment |
1081 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
1082 | | promise(promise && rhs): |
| 1010 | promise(BOOST_RV_REF(promise) rhs): |
1083 | 1011 | future_obtained(rhs.future_obtained) |
1084 | 1012 | { |
1085 | 1013 | future.swap(rhs.future); |
1086 | 1014 | rhs.future_obtained=false; |
1087 | 1015 | } |
1088 | | promise & operator=(promise&& rhs) |
| 1016 | promise & operator=(BOOST_RV_REF(promise) rhs) |
1089 | 1017 | { |
1090 | 1018 | future.swap(rhs.future); |
1091 | 1019 | future_obtained=rhs.future_obtained; |
… |
… |
|
1093 | 1021 | rhs.future_obtained=false; |
1094 | 1022 | return *this; |
1095 | 1023 | } |
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 | 1024 | |
1118 | 1025 | void swap(promise& other) |
1119 | 1026 | { |
… |
… |
|
1209 | 1116 | struct task_object: |
1210 | 1117 | task_base<R> |
1211 | 1118 | { |
| 1119 | struct dummy; |
1212 | 1120 | F f; |
| 1121 | |
1213 | 1122 | task_object(F const& f_): |
1214 | 1123 | f(f_) |
1215 | 1124 | {} |
1216 | | task_object(boost::detail::thread_move_t<F> f_): |
1217 | | f(f_) |
| 1125 | |
| 1126 | task_object(BOOST_RV_REF(F) f_): |
| 1127 | f(::boost::move(f_)) |
1218 | 1128 | {} |
1219 | 1129 | |
1220 | 1130 | void do_run() |
… |
… |
|
1234 | 1144 | struct task_object<void,F>: |
1235 | 1145 | task_base<void> |
1236 | 1146 | { |
| 1147 | struct dummy; |
1237 | 1148 | F f; |
| 1149 | |
1238 | 1150 | task_object(F const& f_): |
1239 | 1151 | f(f_) |
1240 | 1152 | {} |
1241 | | task_object(boost::detail::thread_move_t<F> f_): |
| 1153 | |
| 1154 | task_object(BOOST_RV_REF(F) f_): |
| 1155 | f(::boost::move(f_)) |
| 1156 | {} |
| 1157 | |
| 1158 | void do_run() |
| 1159 | { |
| 1160 | try |
| 1161 | { |
| 1162 | f(); |
| 1163 | this->mark_finished_with_result(); |
| 1164 | } |
| 1165 | catch(...) |
| 1166 | { |
| 1167 | this->mark_exceptional_finish(); |
| 1168 | } |
| 1169 | } |
| 1170 | }; |
| 1171 | |
| 1172 | template<typename R> |
| 1173 | struct task_object<R, R (*)()>: |
| 1174 | task_base<R> |
| 1175 | { |
| 1176 | struct dummy; |
| 1177 | R (*f)(); |
| 1178 | |
| 1179 | task_object(R f_()): |
1242 | 1180 | f(f_) |
1243 | 1181 | {} |
1244 | 1182 | |
… |
… |
|
1246 | 1184 | { |
1247 | 1185 | try |
1248 | 1186 | { |
| 1187 | this->mark_finished_with_result(f()); |
| 1188 | } |
| 1189 | catch(...) |
| 1190 | { |
| 1191 | this->mark_exceptional_finish(); |
| 1192 | } |
| 1193 | } |
| 1194 | }; |
| 1195 | |
| 1196 | template<> |
| 1197 | struct task_object<void, void (*)()>: |
| 1198 | task_base<void> |
| 1199 | { |
| 1200 | struct dummy; |
| 1201 | void (*f)(); |
| 1202 | |
| 1203 | task_object(void f_()): |
| 1204 | f(f_) |
| 1205 | {} |
| 1206 | |
| 1207 | void do_run() |
| 1208 | { |
| 1209 | try |
| 1210 | { |
1249 | 1211 | f(); |
1250 | 1212 | this->mark_finished_with_result(); |
1251 | 1213 | } |
… |
… |
|
1265 | 1227 | boost::shared_ptr<detail::task_base<R> > task; |
1266 | 1228 | bool future_obtained; |
1267 | 1229 | |
1268 | | packaged_task(packaged_task&);// = delete; |
1269 | | packaged_task& operator=(packaged_task&);// = delete; |
1270 | | |
| 1230 | BOOST_MOVABLE_BUT_NOT_COPYABLE(packaged_task) |
| 1231 | struct dummy; |
1271 | 1232 | public: |
1272 | 1233 | packaged_task(): |
1273 | 1234 | future_obtained(false) |
1274 | 1235 | {} |
1275 | 1236 | |
1276 | 1237 | // construction and destruction |
| 1238 | #ifdef BOOST_NO_RVALUE_REFERENCES |
1277 | 1239 | template <class F> |
1278 | | explicit packaged_task(F const& f): |
| 1240 | explicit packaged_task(F const& f, typename ::boost::disable_if< ::boost::is_convertible<F&,::boost::rv<F>&>,dummy*>::type=0): |
1279 | 1241 | task(new detail::task_object<R,F>(f)),future_obtained(false) |
1280 | 1242 | {} |
1281 | | explicit packaged_task(R(*f)()): |
1282 | | task(new detail::task_object<R,R(*)()>(f)),future_obtained(false) |
| 1243 | |
| 1244 | template <class F> |
| 1245 | explicit packaged_task(F& f): |
| 1246 | task(new detail::task_object<R,F>(f)),future_obtained(false) |
1283 | 1247 | {} |
1284 | 1248 | |
1285 | 1249 | template <class F> |
1286 | | explicit packaged_task(boost::detail::thread_move_t<F> f): |
| 1250 | explicit packaged_task(BOOST_RV_REF(F) f): |
| 1251 | task(new detail::task_object<R,F>(boost::move(f))),future_obtained(false) |
| 1252 | {} |
| 1253 | |
| 1254 | template <class F> |
| 1255 | explicit packaged_task(BOOST_CATCH_CONST_RLVALUE(F) f): |
1287 | 1256 | task(new detail::task_object<R,F>(f)),future_obtained(false) |
1288 | 1257 | {} |
| 1258 | #else |
| 1259 | template <class F> |
| 1260 | explicit packaged_task(F&& f): |
| 1261 | task(new detail::task_object<R,typename boost::remove_reference<F>::type>( |
| 1262 | static_cast<typename boost::mpl::if_<boost::is_lvalue_reference<F>, |
| 1263 | typename boost::remove_reference<F>::type const&, F&&>::type>(f))), |
| 1264 | future_obtained(false) |
| 1265 | {} |
| 1266 | #endif |
1289 | 1267 | |
| 1268 | explicit packaged_task(R(*f)()): |
| 1269 | task(new detail::task_object<R,R(*)()>(f)),future_obtained(false) |
| 1270 | {} |
| 1271 | |
| 1272 | |
| 1273 | |
1290 | 1274 | // template <class F, class Allocator> |
1291 | 1275 | // explicit packaged_task(F const& f, Allocator a); |
1292 | 1276 | // template <class F, class Allocator> |
… |
… |
|
1302 | 1286 | } |
1303 | 1287 | |
1304 | 1288 | // assignment |
1305 | | #ifndef BOOST_NO_RVALUE_REFERENCES |
1306 | | packaged_task(packaged_task&& other): |
| 1289 | packaged_task(BOOST_RV_REF(packaged_task) other): |
1307 | 1290 | future_obtained(other.future_obtained) |
1308 | 1291 | { |
1309 | 1292 | task.swap(other.task); |
1310 | 1293 | other.future_obtained=false; |
1311 | 1294 | } |
1312 | | packaged_task& operator=(packaged_task&& other) |
1313 | | { |
1314 | | packaged_task temp(static_cast<packaged_task&&>(other)); |
1315 | | swap(temp); |
1316 | | return *this; |
1317 | | } |
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) |
| 1295 | packaged_task& operator=(BOOST_RV_REF(packaged_task) other) |
1326 | 1296 | { |
1327 | | packaged_task temp(other); |
| 1297 | packaged_task temp(boost::move(other)); |
1328 | 1298 | swap(temp); |
1329 | 1299 | return *this; |
1330 | 1300 | } |
1331 | | operator boost::detail::thread_move_t<packaged_task>() |
1332 | | { |
1333 | | return boost::detail::thread_move_t<packaged_task>(*this); |
1334 | | } |
1335 | | #endif |
1336 | 1301 | |
1337 | 1302 | void swap(packaged_task& other) |
1338 | 1303 | { |
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 | 323 | unique_lock temp(other.move()); |
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 | 330 | unique_lock temp(other.move()); |
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 | 836 | try_lock_wrapper temp(other.move()); |
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) |