HomePhabricator

[coroutines] Add std::experimental::task<T> type

Description

[coroutines] Add std::experimental::task<T> type

Summary:
Adds the coroutine std::experimental::task<T> type described in proposal P1056R0.
See https://wg21.link/P1056R0.

This implementation allows customization of the allocator used to allocate the
coroutine frame by passing std::allocator_arg as the first argument, followed by
the allocator to use.

This supports co_awaiting the same task multiple times. The second and
subsequent times it returns a reference to the already-computed value.

This diff also adds some implementations of other utilities that have potential for
standardization as helpers within the test/... area:

  • sync_wait(awaitable) - See P1171R0
  • manual_reset_event

Move the definition of the aligned_allocation_size helper function
from <experimental/memory_resource> to <experimental/
memory>
so it can be more widely used without pulling in memory_resource.

Outstanding work:

  • Use C++14 keywords directly rather than macro versions eg. use noexcept instead of _NOEXCEPT).
  • Add support for overaligned coroutine frames. This may need wording in the Coroutines TS to support passing the extra std::align_val_t.
  • Eliminate use of if constexpr if we want it to compile under C++14.

Patch by @lewissbaker (Lewis Baker).

Details

Committed
modocacheMar 26 2019, 10:46 AM
Parents
rL357009: [WebAssembly] Support WebAssemblyFunctionInfo serialization
Branches
Unknown
Tags
Unknown

Event Timeline

Apologies, I forgot to include in the commit message:

Reviewers: EricWF, CaseyCarter, GorNishanov

Reviewed By: GorNishanov

Subscribers: libcxx-commits, jdoerfert, jfb, mgorny, ldionne, modocache

Differential Revision: https://reviews.llvm.org/D46140
shafik added a subscriber: shafik.Mar 26 2019, 12:43 PM

It looks like this breaks the lldb build bots, more specifically it looks like all modules builds are broken, see the following log:

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/22456/

I reached out to @modocache offline to provide some more details.