landelare / ue5coro

A C++20 coroutine implementation for Unreal Engine 5 that feels almost native.
BSD 3-Clause Clear License
543 stars 48 forks source link

Coroutine awaiting another coroutine #8

Closed Acren closed 1 year ago

Acren commented 1 year ago

Hey there and thanks for the plugin, looks amazingly useful.

I'm trying to figure out how to await a coroutine from within another coroutine.

The docs seem to say this is possible here: https://github.com/landelare/ue5coro/blob/master/Docs/Async.md#other-coroutines However co_await doesn't appear to work on them in my tests on 1.6.2.

FAsyncCoroutine AMyActor::TestCoroOuter()
{
    co_await TestCoroInner();
}

FAsyncCoroutine AMyActor::TestCoroInner()
{
    co_await UE5Coro::Latent::Seconds(1.0);
}

[C2027] use of undefined type 'UE5Coro::Private::FAsyncAwaiter'

Is this the correct way of doing this? Are there any examples of this anywhere? Much thanks!

landelare commented 1 year ago

You're probably missing a #include. Either #include "UE5Coro/AsyncAwaiters.h" (where this type is) or make your life easier and #include "UE5Coro.h" to get everything.

Acren commented 1 year ago

That was it, thanks!