Also add <stop_token> header to PCH and Doxygen config.
* doc/doxygen/user.cfg.in: Add <stop_token>.
* include/precompiled/stdc++.h: Likewise.
* include/std/stop_token: Fix definition of std::nostopstate.
* testsuite/30_threads/headers/stop_token/synopsis.cc: New test.
* testsuite/30_threads/headers/thread/types_std_c++20.cc: New test.
* testsuite/30_threads/stop_token/stop_source.cc: New test.
* testsuite/30_threads/stop_token/stop_token.cc: Remove unnecessary
dg-require directives. Remove I/O and inclusion of <iostream>.
From-SVN: r278296
+2019-11-15 Jonathan Wakely <jwakely@redhat.com>
+
+ * doc/doxygen/user.cfg.in: Add <stop_token>.
+ * include/precompiled/stdc++.h: Likewise.
+ * include/std/stop_token: Fix definition of std::nostopstate.
+ * testsuite/30_threads/headers/stop_token/synopsis.cc: New test.
+ * testsuite/30_threads/headers/thread/types_std_c++20.cc: New test.
+ * testsuite/30_threads/stop_token/stop_source.cc: New test.
+ * testsuite/30_threads/stop_token/stop_token.cc: Remove unnecessary
+ dg-require directives. Remove I/O and inclusion of <iostream>.
+
2019-11-14 Thomas Rodgers <trodgers@redhat.com>
* include/Makefile.am: Add <stop_token> header.
include/sstream \
include/stack \
include/stdexcept \
+ include/stop_token \
include/streambuf \
include/string \
include/string_view \
#include <numbers>
#include <ranges>
#include <span>
+#include <stop_token>
// #include <syncstream>
#include <version>
#endif
class stop_callback;
struct nostopstate_t { explicit nostopstate_t() = default; };
- inline constexpr nostopstate_t nostopstate();
+ inline constexpr nostopstate_t nostopstate{};
class stop_token
{
--- /dev/null
+// Copyright (C) 2019 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/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <stop_token>
+
+namespace std
+{
+ class stop_token;
+ class stop_source;
+ struct nostopstate_t;
+ template<class>
+ class stop_callback;
+}
+
+namespace gnu
+{
+ constexpr const std::nostopstate_t* tag = &std::nostopstate;
+}
--- /dev/null
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+// { dg-require-gthreads "" }
+
+// Copyright (C) 2019 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 <thread>
+
+void test01()
+{
+ using t_t = std::thread;
+ using j_t = std::jthread;
+
+ using namespace std::this_thread;
+}
--- /dev/null
+// Copyright (C) 2019 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/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <stop_token>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::stop_source ssrc;
+ VERIFY( ssrc.stop_possible() );
+ VERIFY( !ssrc.stop_requested() );
+
+ std::stop_source copy(ssrc);
+ VERIFY( copy.stop_possible() );
+ VERIFY( !copy.stop_requested() );
+ VERIFY( ssrc.stop_possible() );
+ VERIFY( !ssrc.stop_requested() );
+
+ std::stop_source move(std::move(ssrc));
+ VERIFY( move.stop_possible() );
+ VERIFY( !move.stop_requested() );
+ VERIFY( copy.stop_possible() );
+ VERIFY( !copy.stop_requested() );
+ VERIFY( !ssrc.stop_possible() );
+ VERIFY( !ssrc.stop_requested() );
+}
+
+void
+test02()
+{
+ // stop_source(nostopstate_t) constructor is explicit:
+ static_assert(!std::is_convertible_v<std::nostopstate_t, std::stop_source>);
+
+ std::stop_source ssrc(std::nostopstate);
+ VERIFY( !ssrc.stop_possible() );
+ VERIFY( !ssrc.stop_requested() );
+
+ std::stop_source copy(ssrc);
+ VERIFY( !copy.stop_possible() );
+ VERIFY( !copy.stop_requested() );
+ VERIFY( !ssrc.stop_possible() );
+ VERIFY( !ssrc.stop_requested() );
+
+ std::stop_source move(std::move(ssrc));
+ VERIFY( !move.stop_possible() );
+ VERIFY( !move.stop_requested() );
+ VERIFY( !copy.stop_possible() );
+ VERIFY( !copy.stop_requested() );
+ VERIFY( !ssrc.stop_possible() );
+ VERIFY( !ssrc.stop_requested() );
+}
+
+int main()
+{
+ test01();
+ test02();
+}
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-std=gnu++2a -pthread" }
-// { dg-do run }
-// { dg-require-effective-target c++2a }
-// { dg-require-effective-target pthread }
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
#include <stop_token>
-#include <iostream>
#include <testsuite_hooks.h>
int main()
// register callback
bool cb1called{false};
auto cb1 = [&]{
- std::cout << "cb1" << std::endl;
cb1called = true;
};
{