public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/49204] New: remaining issues in <future>
@ 2011-05-28  0:32 redi at gcc dot gnu.org
  2011-05-28  0:41 ` [Bug libstdc++/49204] [C++0x] " redi at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-28  0:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49204

           Summary: remaining issues in <future>
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: redi@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


(this is a placeholder and reminder to myself)

We don't return future_status from the timed waiting functions.


The requirements for async say:

 If the implementation chooses the launch::async policy,
   — a call to a waiting function on an asynchronous return object that
     shares the shared state created by this async call shall block until
     the associated thread has completed, as if joined (30.3.1.5);

The current implementation doesn't meet this requirement,
_Async_state::_M_do_run could make the state ready and unblock waiters
before the thread completes.

Proposed fix: _State_base::_M_wait() already calls _M_run_deferred()
to give a deferred function a chance to run, we could add override it
as _Async_state::_M_run_deferred() and join the thread.


@@ -1325,7 +1325,7 @@
   _M_thread(mem_fn(&_Async_state::_M_do_run), this)
      { }

-      ~_Async_state() { _M_thread.join(); }
+      ~_Async_state() { _M_join(); }

    private:
      void _M_do_run()
@@ -1334,11 +1334,18 @@
        _M_set_result(std::move(__setter));
      }

+      void _M_run_deferred()
+      { _M_join(); }
+
+      void _M_join()
+      { std::call_once(_M_once, &thread::join, ref(_M_thread)); }
+
      template<typename, typename> friend class _Task_setter;
      typedef typename __future_base::_Ptr<_Result<_Res>>::type _Ptr_type;
      _Ptr_type _M_result;
      std::function<_Res()> _M_fn;
      thread _M_thread;
+      once_flag _M_once;
    };

  /// async


That would ensure non-timed waiting functions block as if joined.  It
doesn't handle non-timed waiting functions, but I'm not convinced they
should block.


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

end of thread, other threads:[~2015-05-05  2:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-28  0:32 [Bug libstdc++/49204] New: remaining issues in <future> redi at gcc dot gnu.org
2011-05-28  0:41 ` [Bug libstdc++/49204] [C++0x] " redi at gcc dot gnu.org
2011-05-31 11:12 ` redi at gcc dot gnu.org
2011-05-31 14:00 ` redi at gcc dot gnu.org
2011-12-23 16:13 ` redi at gcc dot gnu.org
2011-12-30 13:12 ` redi at gcc dot gnu.org
2012-01-02 17:56 ` redi at gcc dot gnu.org
2012-02-01  0:20 ` redi at gcc dot gnu.org
2012-02-01  0:25 ` redi at gcc dot gnu.org
2012-02-03  9:22 ` redi at gcc dot gnu.org
2012-08-22 19:20 ` redi at gcc dot gnu.org
2013-03-22 14:42 ` jakub at gcc dot gnu.org
2013-03-23 15:02 ` redi at gcc dot gnu.org
2013-11-20 20:59 ` redi at gcc dot gnu.org
2013-11-20 21:02 ` redi at gcc dot gnu.org
2015-05-05  2:00 ` redi at gcc dot gnu.org

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).