r278364 - in /trunk/libstdc++-v3: ChangeLog inc...

redi@gcc.gnu.org redi@gcc.gnu.org
Sat Nov 16 21:47:00 GMT 2019


Author: redi
Date: Sat Nov 16 21:47:28 2019
New Revision: 278364

URL: https://gcc.gnu.org/viewcvs?rev=278364&root=gcc&view=rev
Log:
libstdc++: Optimize std::jthread construction

This change avoids storing a copy of a stop_token object that isn't
needed and won't be passed to the callable object. This slightly reduces
memory usage when the callable doesn't use a stop_token. It also removes
indirection in the invocation of the callable in the new thread, as
there is no lambda and no additional calls to std::invoke.

It also adds some missing [[nodiscard]] attributes, and the non-member
swap overload for std::jthread.

	* include/std/thread (jthread::jthread()): Use nostopstate constant.
	(jthread::jthread(Callable&&, Args&&...)): Use helper function to
	create std::thread instead of indirection through a lambda. Use
	remove_cvref_t instead of decay_t.
	(jthread::joinable(), jthread::get_id(), jthread::native_handle())
	(jthread::hardware_concurrency()): Add nodiscard attribute.
	(swap(jthread&. jthread&)): Define hidden friend.
	(jthread::_S_create): New helper function for constructor.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/thread



More information about the Libstdc++-cvs mailing list