Commit 71226651 by Jonathan Wakely Committed by Jonathan Wakely

shared_mutex (__shared_mutex_pthread, [...]): New helper types implementing the…

shared_mutex (__shared_mutex_pthread, [...]): New helper types implementing the shared mutex requirements.

	* include/std/shared_mutex (__shared_mutex_pthread,
	__shared_mutex_cv): New helper types implementing the shared mutex
	requirements.
	(shared_mutex): New type for C++17.
	(shared_timed_mutex): Derive from one of the new helper types.
	* testsuite/30_threads/shared_mutex/cons/1.cc: New.
	* testsuite/30_threads/shared_mutex/cons/assign_neg.cc: New.
	* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: New.
	* testsuite/30_threads/shared_mutex/requirements/standard_layout.cc:
	New.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: New.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: New.

From-SVN: r224158
parent e918809c
2015-06-05 Jonathan Wakely <jwakely@redhat.com>
* include/std/shared_mutex (__shared_mutex_pthread,
__shared_mutex_cv): New helper types implementing the shared mutex
requirements.
(shared_mutex): New type for C++17.
(shared_timed_mutex): Derive from one of the new helper types.
* testsuite/30_threads/shared_mutex/cons/1.cc: New.
* testsuite/30_threads/shared_mutex/cons/assign_neg.cc: New.
* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: New.
* testsuite/30_threads/shared_mutex/requirements/standard_layout.cc:
New.
* testsuite/30_threads/shared_mutex/try_lock/1.cc: New.
* testsuite/30_threads/shared_mutex/try_lock/2.cc: New.
2015-06-05 Ville Voutilainen <ville.voutilainen@gmail.com>
Add __is_nothrow_swappable and take it into use.
......
// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++17 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++17 -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++17 " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2015 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
try
{
mutex_type m1;
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do compile }
// { dg-options "-std=gnu++17" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2015 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
void test01()
{
// assign
typedef std::shared_mutex mutex_type;
mutex_type m1;
mutex_type m2;
m1 = m2; // { dg-error "deleted" }
}
// { dg-prune-output "include" }
// { dg-do compile }
// { dg-options "-std=gnu++17" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2015 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
void test01()
{
// assign
typedef std::shared_mutex mutex_type;
mutex_type m1;
mutex_type m2(m1); // { dg-error "deleted" }
}
// { dg-prune-output "include" }
// { dg-do compile }
// { dg-options "-std=gnu++17" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2015 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <testsuite_common_types.h>
void test01()
{
__gnu_test::standard_layout test;
test.operator()<std::shared_mutex>();
}
// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++17 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++17 -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++17 " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2015 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
try
{
mutex_type m;
bool b = m.try_lock();
VERIFY( b );
m.unlock();
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++17 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++17 -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++17 " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2015 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 3, 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <thread>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
try
{
mutex_type m;
m.lock();
bool b;
std::thread t([&] {
try
{
b = m.try_lock();
}
catch (const std::system_error& e)
{
VERIFY( false );
}
});
t.join();
VERIFY( !b );
m.unlock();
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment