⚡ Async/Await
Asynchronous programming in RADS
Async Functions
Use async blast to declare async functions.
import net;
async blast fetch_data(str url) -> str {
turbo stream response = await net.http_get(url);
return await response.text();
}
async blast main() {
turbo str data = await fetch_data("https://api.example.com");
echo(data);
}
Await Keyword
Use await to wait for async operations.
Spawn for Concurrency
Use spawn to run tasks concurrently.
async blast task1() {
echo("Task 1 running");
}
async blast task2() {
echo("Task 2 running");
}
async blast main() {
spawn task1();
spawn task2();
echo("Both tasks spawned");
}
Stream Type
The stream type represents async I/O streams.
Async Features
async blast- Async function declarationawait- Wait for async operationspawn- Concurrent executionstream- Async I/O type