aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2009-01-18 12:38:10 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2009-01-18 12:38:10 +0000
commit8b6ded8d4ff7292cc0c4d9c24a6670d97755aaeb (patch)
treed3e3ad76e04a0068362fb9a131ae775c32b03bcb
parent9d2cc6f08117772029621e01bd10e1bc47b9d7b6 (diff)
downloadgcc-8b6ded8d4ff7292cc0c4d9c24a6670d97755aaeb.zip
gcc-8b6ded8d4ff7292cc0c4d9c24a6670d97755aaeb.tar.gz
gcc-8b6ded8d4ff7292cc0c4d9c24a6670d97755aaeb.tar.bz2
thread (__thread_data_base::__run): Make non-const.
* include/std/thread (__thread_data_base::__run): Make non-const. * testsuite/30_threads/thread/cons/5.cc: New. From-SVN: r143483
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/std/thread4
-rw-r--r--libstdc++-v3/testsuite/30_threads/thread/cons/5.cc87
3 files changed, 94 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 30287e8..786a1e3 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-18 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/std/thread (__thread_data_base::__run): Make non-const.
+ * testsuite/30_threads/thread/cons/5.cc: New.
+
2009-01-16 Benjamin Kosnik <bkoz@redhat.com>
* src/Makefile.am (sources): Add math_stubs_float.cc.
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index 422e362..00fb018 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -65,7 +65,7 @@ namespace std
__thread_data_base() = default;
virtual ~__thread_data_base() = default;
- virtual void __run() const = 0;
+ virtual void __run() = 0;
__gthread_t _M_thread_handle;
__thread_data_ptr _M_this_ptr;
@@ -80,7 +80,7 @@ namespace std
: _M_func(std::forward<_Callable>(__f))
{ }
- void __run() const
+ void __run()
{ _M_func(); }
private:
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc
new file mode 100644
index 0000000..35ea25a
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/5.cc
@@ -0,0 +1,87 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <functional> // std::unary_function
+#include <utility> // std::ref
+#include <thread>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+struct nonconst : public std::unary_function<std::thread::id&, void>
+{
+ void operator()(std::thread::id& id)
+ {
+ id = std::this_thread::get_id();
+ }
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ try
+ {
+ std::thread::id t1_id1;
+ nonconst c1;
+ std::thread t1(std::ref(c1), std::ref(t1_id1));
+ std::thread::id t1_id2 = t1.get_id();
+ VERIFY( t1.joinable() );
+ t1.join();
+ VERIFY( !t1.joinable() );
+ VERIFY( t1_id1 == t1_id2 );
+
+ std::thread::id t2_id1;
+ nonconst c2;
+ std::thread t2(c2, std::ref(t2_id1));
+ std::thread::id t2_id2 = t2.get_id();
+ VERIFY( t2.joinable() );
+ t2.join();
+ VERIFY( !t2.joinable() );
+ VERIFY( t2_id1 == t2_id2 );
+ }
+ catch (const std::system_error&)
+ {
+ VERIFY( false );
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}