[patch libstdc++] Optimize synchronization in std::future if futexes are available.

Jonathan Wakely jwakely@redhat.com
Sun Jan 18 14:41:00 GMT 2015


On 16/01/15 18:00 +0100, Torvald Riegel wrote:
>+namespace std _GLIBCXX_VISIBILITY(default)
>+{
>+_GLIBCXX_BEGIN_NAMESPACE_VERSION
>+
>+  bool
>+  __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr,
>+      unsigned __val,
>+      bool __has_timeout, chrono::seconds __s, chrono::nanoseconds __ns)
>+  {
>+    if (!__has_timeout)
>+      {
>+	// Ignore whether we actually succeeded to block because at worst,
>+	// we will fall back to spin-waiting.  The only thing we could do
>+	// here on errors is abort.
>+	int ret __attribute__((unused));
>+	ret = syscall (SYS_futex, __addr, futex_wait_op, __val);
>+	_GLIBCXX_DEBUG_ASSERT(ret == 0 || errno == EINTR || errno == EAGAIN);

I've just noticed these debug assertions in the futex.cc file, which
will never fire because the library isn't build with -D_GLIBCXX_DEBUG
defined. We should decide whether other errors are necessary to handle
and either throw an exception or std::terminate().



More information about the Libstdc++ mailing list