Are Verse coroutines (async functions) compatible with OS threads?

According to the Verse glossary coroutines are synonymous with async functions. This is a bit of a departure from, say, C#, where coroutines are implemented with generators, while async functions are a framework over OS threads.

I assume (and this is a big assumption) to keep them lightweight that coroutines in Verse (ok I’ll have to start calling them async functions) are serviced during the game tick, as opposed to threads that will be serviced by the OS and will be asynchronous of the tick.

So will async functions be compatible with OS threads? I would assume through some sort of queue that will be drained when the game tick occurs?

And will it be a unified syntax? So I could make, for example, REST API calls in my async functions along with standard coroutine calls.

1 Like

Verse is single-threaded, so they work the same as JavaScript async functions - when first called (such as from a spawn or race), they run up until they hit their first suspending function, then pass off to the next expression and resume when they’ve completed

Async functions like Sleep will run after a game tick since the function will complete when at least that amount of time has passed, while event.Signal will cause corresponding event.Await listeners to run immediately after, but always one at a time

1 Like

So I guess we can assume that any native threaded functions (like REST calls) will signal the event system to work with Verse concurrency?

Yup exactly, just like fetch in JavaScript - although such an API won’t ever exist for Fortnite

1 Like

Hah, yeah I just found Tim Sweeny’s “wild west” comment :smiley: Thanks for your insight on this, I’m having a lot of fun with Verse, it’s got some interesting concepts, and begging lots of questions.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.