Skip to content

Commit

Permalink
Thread: remove some warnings + rename BOOST_EXPLICIT_MOVE by BOOST_TH…
Browse files Browse the repository at this point in the history
…READ_MAKE_RV_REF

[SVN r77918]
  • Loading branch information
viboes committed Apr 11, 2012
1 parent e9ceaaa commit f970c9f
Show file tree
Hide file tree
Showing 49 changed files with 367 additions and 138 deletions.
8 changes: 4 additions & 4 deletions doc/compliance.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
http://www.boost.org/LICENSE_1_0.txt).
]

[section:compliance Compliance and Extension]
[section:compliance Conformace and Extension]

[section:cpp11 C++11 standard Thread library]


[table Compliance C++11 standard
[table C++11 standard Conformace
[[Section] [Description] [Status] [Comments] [Ticket]]
[[30] [Thread support library] [Partial] [-] [-]]
[[30.1] [General] [-] [-] [-]]
Expand Down Expand Up @@ -69,7 +69,7 @@
[[30.6.6] [Class template future] [Partial] [allocator,unique_future is the closest to future, renamed in V2] [#6228]]
[[30.6.7] [Class template shared_future] [Partial] [allocator] [#6228]]
[[30.6.8] [Function template async] [No] [async] [#4710]]
[[30.6.8] [Class template packaged_task] [Partial] [move] [#yyyy]]
[[30.6.9] [Class template packaged_task] [Partial] [move] [#yyyy]]
]

[/
Expand All @@ -89,7 +89,7 @@

[section:shared Shared Locking extensions]

[table Compliance with Howard's Shared Locking proposal
[table Howard's Shared Locking Proposal Conformace
[[Section] [Description] [Status] [Comments]]
[[X] [Shared Locking] [Yes] [Needs `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION]]
[[X.1] [Shared Lockables Concepts] [Yes] [ - ]]
Expand Down
2 changes: 1 addition & 1 deletion doc/emulations.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ To make the code portable Boost.Thread uses a macro BOOST_MOVE_RVALUE that can b

thread mkth()
{
return BOOST_EXPLICIT_MOVE(thread(f));
return BOOST_THREAD_MAKE_RV_REF(thread(f));
}

See the Boost.Move documentation for a complete description on how to declare new Movable classes and its limitations.
Expand Down
2 changes: 1 addition & 1 deletion example/condition.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <iostream>
Expand Down
3 changes: 2 additions & 1 deletion example/monitor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <vector>
Expand Down Expand Up @@ -89,6 +89,7 @@ class buffer_t
template <typename M>
void do_test(M* dummy=0)
{
(void)dummy;
typedef buffer_t<M> buffer_type;
buffer_type::get_buffer();
boost::thread thrd1(&buffer_type::do_receiver_thread);
Expand Down
2 changes: 1 addition & 1 deletion example/once.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void thread_proc()
boost::call_once(&init, once);
}

int main(int argc, char* argv[])
int main()
{
boost::thread_group threads;
for (int i=0; i<5; ++i)
Expand Down
2 changes: 1 addition & 1 deletion example/shared_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int main()
v.push_back(&thr2);
boost::thread thr3(test_w);
v.push_back(&thr3);
for (int i = 0; i < v.size(); ++i)
for (std::size_t i = 0; i < v.size(); ++i)
v[i]->join();
Clock::time_point t1 = Clock::now();
std::cout << sec(t1-t0) << '\n';
Expand Down
4 changes: 2 additions & 2 deletions example/starvephil.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/mutex.hpp>
Expand Down Expand Up @@ -164,7 +164,7 @@ class thread_adapter
void* _param;
};

int main(int argc, char* argv[])
int main()
{
boost::thread thrd_chef(&chef);
phil p[] = { phil(0), phil(1), phil(2), phil(3), phil(4) };
Expand Down
4 changes: 2 additions & 2 deletions example/thread.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/thread.hpp>
Expand All @@ -25,7 +25,7 @@ struct thread_alarm
int m_secs;
};

int main(int argc, char* argv[])
int main()
{
int secs = 5;
std::cout << "setting alarm for 5 seconds..." << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions example/thread_group.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/thread.hpp>
Expand All @@ -16,7 +16,7 @@ void increment_count()
std::cout << "count = " << ++count << std::endl;
}

int main(int argc, char* argv[])
int main()
{
boost::thread_group threads;
for (int i = 0; i < 10; ++i)
Expand Down
4 changes: 2 additions & 2 deletions example/tss.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/thread.hpp>
Expand All @@ -27,7 +27,7 @@ void thread_proc()
}
}

int main(int argc, char* argv[])
int main()
{
boost::thread_group threads;
for (int i=0; i<5; ++i)
Expand Down
4 changes: 2 additions & 2 deletions example/xtime.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (C) 2001-2003
// William E. Kempf
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>

int main(int argc, char* argv[])
int main()
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
Expand Down
51 changes: 45 additions & 6 deletions include/boost/thread/detail/move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_cv.hpp>
#endif

#include <boost/move/move.hpp>

#include <boost/config/abi_prefix.hpp>
//#include <boost/config/abi_prefix.hpp>

namespace boost
{
Expand Down Expand Up @@ -62,15 +63,53 @@ namespace boost
}

#if ! defined BOOST_NO_RVALUE_REFERENCES
//&& ! defined BOOST_NO_DELETED_FUNCTIONS
#define BOOST_EXPLICIT_MOVE(RVALUE) RVALUE
#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE


#elif ! defined BOOST_NO_RVALUE_REFERENCES && defined BOOST_MSVC
#define BOOST_EXPLICIT_MOVE(RVALUE) RVALUE
#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE
#else

namespace boost
{
namespace detail
{

#if defined BOOST_THREAD_USES_MOVE
#define BOOST_THREAD_RV_REF(TYPE) BOOST_RV_REF(TYPE)
#else
#define BOOST_EXPLICIT_MOVE(RVALUE) RVALUE.move()
#define BOOST_THREAD_RV_REF(TYPE) thread_move_t<TYPE>
#endif
template <typename T>
BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
make_rv_ref(T v) BOOST_NOEXCEPT
{
return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
}
// template <typename T>
// BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
// make_rv_ref(T &v) BOOST_NOEXCEPT
// {
// return (BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
// }
// template <typename T>
// const BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type)
// make_rv_ref(T const&v) BOOST_NOEXCEPT
// {
// return (const BOOST_THREAD_RV_REF(typename ::boost::remove_cv<typename ::boost::remove_reference<T>::type>::type))(v);
// }
}
}

#define BOOST_THREAD_MAKE_RV_REF(RVALUE) RVALUE.move()
//#define BOOST_THREAD_MAKE_RV_REF(RVALUE) boost::detail::make_rv_ref(RVALUE)
#endif




#include <boost/config/abi_suffix.hpp>
//#include <boost/config/abi_suffix.hpp>

#endif
4 changes: 0 additions & 4 deletions include/boost/thread/detail/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
#ifndef BOOST_NO_IOSTREAM
#include <ostream>
#endif
#if defined BOOST_THREAD_USES_MOVE
#include <boost/move/move.hpp>
#else
#include <boost/thread/detail/move.hpp>
#endif
#include <boost/thread/mutex.hpp>
#include <boost/thread/xtime.hpp>
#include <boost/thread/detail/thread_heap_alloc.hpp>
Expand Down
5 changes: 3 additions & 2 deletions include/boost/thread/locks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ namespace boost
}
BOOST_THREAD_EXPLICIT_LOCK_CONVERSION unique_lock(boost::rv<upgrade_lock<Mutex> >& other);

operator ::boost::rv<unique_lock<Mutex> >&()
//operator boost::rv<boost::unique_lock<boost::mutex> >&
operator boost::rv<unique_lock<Mutex> >&()
{
return *static_cast< ::boost::rv<unique_lock<Mutex> >* >(this);
}
Expand Down Expand Up @@ -1948,7 +1949,7 @@ namespace boost
{
if(source)
{
*source=BOOST_EXPLICIT_MOVE(upgrade_lock<Mutex>(::boost::move(exclusive)));
*source=BOOST_THREAD_MAKE_RV_REF(upgrade_lock<Mutex>(::boost::move(exclusive)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/boost/thread/reverse_lock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace boost
{
if (mtx) {
mtx->lock();
m = BOOST_EXPLICIT_MOVE(Lock(*mtx, adopt_lock));
m = BOOST_THREAD_MAKE_RV_REF(Lock(*mtx, adopt_lock));
}
}

Expand Down
21 changes: 14 additions & 7 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ project
<toolset>darwin:<cxxflags>-Wextra
<toolset>darwin:<cxxflags>-pedantic
<toolset>darwin:<cxxflags>-Wno-long-long
#<toolset>darwin:<cxxflags>-ansi
#<toolset>darwin:<cxxflags>-ansi # doesn't work for 4.1.2
<toolset>darwin:<cxxflags>-fpermissive

#<toolset>pathscale:<cxxflags>-Wextra
Expand All @@ -44,7 +44,7 @@ project
<toolset>clang:<cxxflags>-pedantic
<toolset>clang:<cxxflags>-Wno-long-long
<toolset>clang:<cxxflags>-ansi
#<toolset>clang:<cxxflags>-fpermissive
#<toolset>clang:<cxxflags>-fpermissive # doesn't work

<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
Expand All @@ -53,8 +53,10 @@ project
<toolset>gcc-mingw-4.7.0:<cxxflags>-fdiagnostics-show-option
<toolset>gcc-mingw-4.8.0:<cxxflags>-fdiagnostics-show-option

#<toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
<toolset>darwin-4.6.2:<cxxflags>-ansi
#<toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor # doesn't work
<toolset>darwin-4.7.0:<cxxflags>-ansi
<toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor

#<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>clang-2.8:<cxxflags>-Wno-unused-function
Expand Down Expand Up @@ -463,11 +465,16 @@ rule thread-compile-fail-V2 ( sources : reqs * : name )
[ thread-run2 ./threads/thread/members/swap_pass.cpp : thread__swap_p ]
[ thread-run2 ./threads/thread/non_members/swap_pass.cpp : swap_threads_p ]
[ thread-run2 ./threads/thread/static/hardware_concurrency_pass.cpp : thread__hardware_concurrency_p ]
#[ thread-run2 ./threads/container/thread_vector_pass.cpp : thread_vector_p ]
#[ thread-run2 ./threads/container/thread_ptr_list_pass.cpp : thread_ptr_list_p ]
;

#explicit examples ;
#explicit ts_container ;
test-suite ts_container
:
[ thread-run2 ./threads/container/thread_vector_pass.cpp : container__thread_vector_p ]
[ thread-run2 ./threads/container/thread_ptr_list_pass.cpp : container__thread_ptr_list_p ]
;

explicit examples ;
test-suite ts_examples
:
[ thread-run ../example/monitor.cpp ]
Expand Down
12 changes: 6 additions & 6 deletions test/sync/futures/future/dtor_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main()
{
boost::promise<T> p(boost::allocator_arg, test_allocator<T>());
BOOST_TEST(test_alloc_base::count == 1);
f = BOOST_EXPLICIT_MOVE(p.get_future());
f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
BOOST_TEST(test_alloc_base::count == 1);
BOOST_TEST(f.valid());
}
Expand All @@ -51,7 +51,7 @@ int main()
{
boost::promise<T> p(boost::allocator_arg, test_allocator<int>());
BOOST_TEST(test_alloc_base::count == 1);
f = BOOST_EXPLICIT_MOVE(p.get_future());
f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
BOOST_TEST(test_alloc_base::count == 1);
BOOST_TEST(f.valid());
}
Expand All @@ -65,7 +65,7 @@ int main()
{
boost::promise<T> p(boost::allocator_arg, test_allocator<T>());
BOOST_TEST(test_alloc_base::count == 1);
f = BOOST_EXPLICIT_MOVE(p.get_future());
f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
BOOST_TEST(test_alloc_base::count == 1);
BOOST_TEST(f.valid());
}
Expand All @@ -79,7 +79,7 @@ int main()
boost::future<T> f;
{
boost::promise<T> p;
f = BOOST_EXPLICIT_MOVE(p.get_future());
f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
BOOST_TEST(f.valid());
}
BOOST_TEST(f.valid());
Expand All @@ -89,7 +89,7 @@ int main()
boost::future<T> f;
{
boost::promise<T> p;
f = BOOST_EXPLICIT_MOVE(p.get_future());
f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
BOOST_TEST(f.valid());
}
BOOST_TEST(f.valid());
Expand All @@ -99,7 +99,7 @@ int main()
boost::future<T> f;
{
boost::promise<T> p;
f = BOOST_EXPLICIT_MOVE(p.get_future());
f = BOOST_THREAD_MAKE_RV_REF(p.get_future());
BOOST_TEST(f.valid());
}
BOOST_TEST(f.valid());
Expand Down
Loading

0 comments on commit f970c9f

Please sign in to comment.