public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] std::future::wait_* improvements
@ 2019-10-27 15:47 Mike Crowe
  2019-10-27 15:46 ` [PATCH v4 5/7] libstdc++ futex: Loop when waiting against arbitrary clock Mike Crowe
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Mike Crowe @ 2019-10-27 15:47 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: Mike Crowe

v1 of this series was originally posted back in September 2017 (see
https://gcc.gnu.org/ml/libstdc++/2017-09/msg00083.html )

v2 of this series was originally posted back in January 2018 (see
https://gcc.gnu.org/ml/libstdc++/2018-01/msg00035.html )

v3 of this series was originally posted back in August 2018 (see
https://gcc.gnu.org/ml/libstdc++/2018-08/msg00001.html )

Changes since v3:

* Update libstdc++-v3/config/abi/pre/gnu.ver as recommended by
  Jonathan Wakely in
  https://gcc.gnu.org/ml/libstdc++/2018-08/msg00015.html .

* Replace _GLIBCXX_DEBUG_ASSERT with __glibcxx_assert in futex.cc as
  recommended by Jonathan Wakely in
  https://gcc.gnu.org/ml/libstdc++/2018-08/msg00014.html .

* Incorporate extra patch originally posted separately in
  https://gcc.gnu.org/ml/libstdc++/2018-08/msg00017.html .

* Rename incorrect futex_clock_realtime_unavailable to
  futex_clock_monotonic_unavailable in comment.	 Spotted by Jonathan
  Wakely.

* Improve commit messages to use GNU two-spaces-after-periods style
  and add changelogs.

* Restrict lines to eighty columns or less.

* Remove unnecessarily-added steady_clock_copy from test - slow_clock
  works just as well.

* A few other minor tweaks to tests and comments.

Combined ChangeLog entry (generated from the separate messages in each
commit):

2019-10-27  Mike Crowe	<mac@mcrowe.com>

	* libstdc++-v3/testsuite/30_threads/async/async.cc (test02):
	Test steady_clock with std::future::wait_until.	 (test03): Add
	new test templated on clock type waiting for future associated
	with async to resolve.	(main): Call test03 to test both
	system_clock and steady_clock.

	* libstdc++-v3/src/c++11/futex.cc: Add new constants for
	required futex flags.  Add futex_clock_realtime_unavailable
	flag to store result of trying to use FUTEX_CLOCK_REALTIME.
	(__atomic_futex_unsigned_base::_M_futex_wait_until): Try to
	use FUTEX_WAIT_BITSET with FUTEX_CLOCK_REALTIME and only fall
	back to using gettimeofday and FUTEX_WAIT if that's not
	supported.

	* libstdc++-v3/config/abi/pre/gnu.ver: Update for addition of
	__atomic_futex_unsigned_base::_M_futex_wait_until_steady.
	* libstdc++-v3/include/bits/atomic_futex.h
	(__atomic_futex_unsigned_base): Add comments to clarify that
	_M_futex_wait_until _M_load_and_test_until use CLOCK_REALTIME.
	Declare new _M_futex_wait_until_steady and
	_M_load_and_text_until_steady methods that use
	CLOCK_MONOTONIC.  Add _M_load_and_test_until_impl and
	_M_load_when_equal_until overloads that accept a steady_clock
	time_point and use these new methods.
	* libstdc++-v3/src/c++11/futex.cc: Include headers required
	for clock_gettime. Add futex_clock_monotonic_flag constant to
	tell futex to use CLOCK_MONOTONIC to match the existing
	futex_clock_realtime_flag.  Add
	futex_clock_monotonic_unavailable to store the result of
	trying to use CLOCK_MONOTONIC.
	(__atomic_futex_unsigned_base::_M_futex_wait_until_steady):
	Add new variant of _M_futex_wait_until that uses
	CLOCK_MONOTONIC to support waiting using steady_clock.

	* libstdc++-v3/include/bits/atomic_futex.h:
	(__atomic_futex_unsigned): Change __clock_t typedef to use
	steady_clock so that unknown clocks are synced to it rather
	than system_clock. Change existing __clock_t overloads of
	_M_load_and_text_until_impl and _M_load_when_equal_until to
	use system_clock explicitly. Remove comment about DR 887 since
	these changes address that problem as best as we currently
	able.

	* libstdc++-v3/include/bits/atomic_futex.h:
	(__atomic_futex_unsigned) Add loop to _M_load_when_equal_until
	on generic _Clock to check the timeout against _Clock again
	after _M_load_when_equal_until returns indicating a timeout.
	* libstdc++-v3/testsuite/30_threads/async/async.cc: Invent
	slow_clock that runs at an eleventh of steady_clock's
	speed. Use it to test the user-supplied-clock variant of
	__atomic_futex_unsigned::_M_load_when_equal_until works
	generally with test03 and loops correctly when the timeout
	time hasn't been reached in test04.

	* libstdc++-v3/include/bits/atomic_futex.h:
	(__atomic_futex_unsigned::_M_load_when_equal_for): Round up
	timeout if required after conversion to reference clock
	duration.
	* libstdc++-v3/testsuite/30_threads/async/async.cc:
	(test_pr68519): New test for the equivalent of PR
	libstdc++/68519.

Mike Crowe (7):
  libstdc++: Improve async test
  libstdc++ futex: Use FUTEX_CLOCK_REALTIME for wait
  libstdc++ futex: Support waiting on std::chrono::steady_clock directly
  libstdc++ atomic_futex: Use std::chrono::steady_clock as reference clock
  libstdc++ futex: Loop when waiting against arbitrary clock
  libstdc++ atomic_futex: Avoid rounding errors in std::future::wait_for
  libstdc++: Extra async tests, not for merging

 libstdc++-v3/config/abi/pre/gnu.ver              |  10 +-
 libstdc++-v3/include/bits/atomic_futex.h         |  95 +++++++--
 libstdc++-v3/src/c++11/futex.cc                  | 119 +++++++++++-
 libstdc++-v3/testsuite/30_threads/async/async.cc | 170 ++++++++++++++++-
 4 files changed, 379 insertions(+), 15 deletions(-)

base-commit: 541ec0fe27585fce2b27750ca2bb1cf8985b043e
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-27 15:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-27 15:47 [PATCH v4 0/7] std::future::wait_* improvements Mike Crowe
2019-10-27 15:46 ` [PATCH v4 5/7] libstdc++ futex: Loop when waiting against arbitrary clock Mike Crowe
2019-10-27 15:47 ` [PATCH v4 4/7] libstdc++ atomic_futex: Use std::chrono::steady_clock as reference clock Mike Crowe
2019-10-27 15:47 ` [PATCH v4 1/7] libstdc++: Improve async test Mike Crowe
2019-10-27 15:47 ` [PATCH v4 2/7] libstdc++ futex: Use FUTEX_CLOCK_REALTIME for wait Mike Crowe
2019-10-27 15:47 ` [PATCH v4 7/7] libstdc++: Extra async tests, not for merging Mike Crowe
2019-10-27 15:47 ` [PATCH v4 6/7] libstdc++ atomic_futex: Avoid rounding errors in std::future::wait_for Mike Crowe
2019-10-27 15:50 ` [PATCH v4 3/7] libstdc++ futex: Support waiting on std::chrono::steady_clock directly Mike Crowe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).