mirror of
https://github.com/boostorg/thread.git
synced 2026-02-09 11:32:12 +00:00
Compare commits
1 Commits
sandbox-br
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b5296a4cc |
@@ -39,13 +39,10 @@ namespace boost
|
||||
public detail::thread_data_base
|
||||
{
|
||||
public:
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
thread_data(F&& f_):
|
||||
f(static_cast<F&&>(f_))
|
||||
{}
|
||||
thread_data(F& f_):
|
||||
f(f_)
|
||||
{}
|
||||
#else
|
||||
thread_data(F f_):
|
||||
f(f_)
|
||||
@@ -122,7 +119,7 @@ namespace boost
|
||||
|
||||
detail::thread_data_ptr get_thread_info() const;
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename F>
|
||||
static inline detail::thread_data_ptr make_thread_info(F&& f)
|
||||
{
|
||||
@@ -130,7 +127,7 @@ namespace boost
|
||||
}
|
||||
static inline detail::thread_data_ptr make_thread_info(void (*f)())
|
||||
{
|
||||
return detail::thread_data_ptr(detail::heap_new<detail::thread_data<void(*)()> >(static_cast<void(*&&)()>(f)));
|
||||
return detail::thread_data_ptr(detail::heap_new<detail::thread_data<void(*)()> >(f));
|
||||
}
|
||||
#else
|
||||
template<typename F>
|
||||
@@ -144,8 +141,8 @@ namespace boost
|
||||
return detail::thread_data_ptr(detail::heap_new<detail::thread_data<F> >(f));
|
||||
}
|
||||
|
||||
#endif
|
||||
struct dummy;
|
||||
#endif
|
||||
public:
|
||||
#ifdef __SUNPRO_CC
|
||||
thread(const volatile thread&);
|
||||
@@ -153,22 +150,13 @@ namespace boost
|
||||
thread();
|
||||
~thread();
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_MSVC
|
||||
template <class F>
|
||||
explicit thread(F f,typename disable_if<boost::is_convertible<F&,detail::thread_move_t<F> >, dummy* >::type=0):
|
||||
thread_info(make_thread_info(f))
|
||||
{
|
||||
start_thread();
|
||||
}
|
||||
#else
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template <class F>
|
||||
thread(F&& f):
|
||||
thread_info(make_thread_info(static_cast<F&&>(f)))
|
||||
{
|
||||
start_thread();
|
||||
}
|
||||
#endif
|
||||
|
||||
thread(thread&& other)
|
||||
{
|
||||
@@ -355,14 +343,10 @@ namespace boost
|
||||
return lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
inline thread&& move(thread& t)
|
||||
{
|
||||
return static_cast<thread&&>(t);
|
||||
}
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
inline thread&& move(thread&& t)
|
||||
{
|
||||
return static_cast<thread&&>(t);
|
||||
return t;
|
||||
}
|
||||
#else
|
||||
inline detail::thread_move_t<thread> move(detail::thread_move_t<thread> t)
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace boost
|
||||
struct future_traits
|
||||
{
|
||||
typedef boost::scoped_ptr<T> storage_type;
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
typedef T const& source_reference_type;
|
||||
struct dummy;
|
||||
typedef typename boost::mpl::if_<boost::is_fundamental<T>,dummy&,T&&>::type rvalue_source_type;
|
||||
@@ -404,14 +404,13 @@ namespace boost
|
||||
|
||||
struct all_futures_lock
|
||||
{
|
||||
typedef std::vector<registered_waiter>::size_type count_type;
|
||||
count_type count;
|
||||
unsigned count;
|
||||
boost::scoped_array<boost::unique_lock<boost::mutex> > locks;
|
||||
|
||||
all_futures_lock(std::vector<registered_waiter>& futures):
|
||||
count(futures.size()),locks(new boost::unique_lock<boost::mutex>[count])
|
||||
{
|
||||
for(count_type i=0;i<count;++i)
|
||||
for(unsigned i=0;i<count;++i)
|
||||
{
|
||||
locks[i]=boost::unique_lock<boost::mutex>(futures[i].future->mutex);
|
||||
}
|
||||
@@ -634,7 +633,7 @@ namespace boost
|
||||
~unique_future()
|
||||
{}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
unique_future(unique_future && other)
|
||||
{
|
||||
future.swap(other.future);
|
||||
@@ -769,7 +768,7 @@ namespace boost
|
||||
future=other.future;
|
||||
return *this;
|
||||
}
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
shared_future(shared_future && other)
|
||||
{
|
||||
future.swap(other.future);
|
||||
@@ -931,7 +930,7 @@ namespace boost
|
||||
}
|
||||
|
||||
// Assignment
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
promise(promise && rhs):
|
||||
future_obtained(rhs.future_obtained)
|
||||
{
|
||||
@@ -1065,7 +1064,7 @@ namespace boost
|
||||
}
|
||||
|
||||
// Assignment
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
promise(promise && rhs):
|
||||
future_obtained(rhs.future_obtained)
|
||||
{
|
||||
@@ -1285,7 +1284,7 @@ namespace boost
|
||||
}
|
||||
|
||||
// assignment
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
packaged_task(packaged_task&& other):
|
||||
future_obtained(other.future_obtained)
|
||||
{
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace boost
|
||||
{
|
||||
timed_lock(target_time);
|
||||
}
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
unique_lock(unique_lock&& other):
|
||||
m(other.m),is_locked(other.is_locked)
|
||||
{
|
||||
@@ -321,17 +321,17 @@ namespace boost
|
||||
swap(temp);
|
||||
return *this;
|
||||
}
|
||||
void swap(unique_lock& other)
|
||||
{
|
||||
std::swap(m,other.m);
|
||||
std::swap(is_locked,other.is_locked);
|
||||
}
|
||||
void swap(detail::thread_move_t<unique_lock<Mutex> > other)
|
||||
{
|
||||
std::swap(m,other->m);
|
||||
std::swap(is_locked,other->is_locked);
|
||||
}
|
||||
#endif
|
||||
void swap(unique_lock& other)
|
||||
{
|
||||
std::swap(m,other.m);
|
||||
std::swap(is_locked,other.is_locked);
|
||||
}
|
||||
|
||||
~unique_lock()
|
||||
{
|
||||
@@ -416,30 +416,25 @@ namespace boost
|
||||
friend class upgrade_lock<Mutex>;
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename Mutex>
|
||||
void swap(unique_lock<Mutex>&& lhs,unique_lock<Mutex>&& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<typename Mutex>
|
||||
void swap(unique_lock<Mutex>& lhs,unique_lock<Mutex>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename Mutex>
|
||||
inline unique_lock<Mutex>&& move(unique_lock<Mutex>&& ul)
|
||||
{
|
||||
return static_cast<unique_lock<Mutex>&&>(ul);
|
||||
}
|
||||
|
||||
template<typename Mutex>
|
||||
inline unique_lock<Mutex>&& move(unique_lock<Mutex>& ul)
|
||||
{
|
||||
return static_cast<unique_lock<Mutex>&&>(ul);
|
||||
return ul;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -540,24 +535,24 @@ namespace boost
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
void swap(shared_lock&& other)
|
||||
{
|
||||
std::swap(m,other.m);
|
||||
std::swap(is_locked,other.is_locked);
|
||||
}
|
||||
#else
|
||||
void swap(shared_lock& other)
|
||||
{
|
||||
std::swap(m,other.m);
|
||||
std::swap(is_locked,other.is_locked);
|
||||
}
|
||||
void swap(boost::detail::thread_move_t<shared_lock<Mutex> > other)
|
||||
{
|
||||
std::swap(m,other->m);
|
||||
std::swap(is_locked,other->is_locked);
|
||||
}
|
||||
#endif
|
||||
void swap(shared_lock& other)
|
||||
{
|
||||
std::swap(m,other.m);
|
||||
std::swap(is_locked,other.is_locked);
|
||||
}
|
||||
|
||||
Mutex* mutex() const
|
||||
{
|
||||
@@ -634,7 +629,7 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename Mutex>
|
||||
void swap(shared_lock<Mutex>&& lhs,shared_lock<Mutex>&& rhs)
|
||||
{
|
||||
@@ -780,7 +775,7 @@ namespace boost
|
||||
};
|
||||
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename Mutex>
|
||||
unique_lock<Mutex>::unique_lock(upgrade_lock<Mutex>&& other):
|
||||
m(other.m),is_locked(other.is_locked)
|
||||
@@ -880,7 +875,7 @@ namespace boost
|
||||
try_lock_wrapper(Mutex& m_,try_to_lock_t):
|
||||
base(m_,try_to_lock)
|
||||
{}
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
try_lock_wrapper(try_lock_wrapper&& other):
|
||||
base(other.move())
|
||||
{}
|
||||
@@ -968,7 +963,7 @@ namespace boost
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename Mutex>
|
||||
void swap(try_lock_wrapper<Mutex>&& lhs,try_lock_wrapper<Mutex>&& rhs)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace boost
|
||||
return new T();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename T,typename A1>
|
||||
inline T* heap_new(A1&& a1)
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace boost
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename T,typename A1>
|
||||
inline T* heap_new(A1&& a1)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
template<typename T>
|
||||
typename boost::remove_reference<T>::type&& cast_to_rval(T&& t)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
X():
|
||||
i(42)
|
||||
{}
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#ifdef BOOST_HAS_RVALUE_REFS
|
||||
X(X&& other):
|
||||
i(other.i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user