Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Awaiter await-all

An asset by Nights
The page banner background of a mountain and forest
Awaiter await-all hero image

Quick Information

0 ratings
Awaiter await-all icon image
Nights
Awaiter await-all

A Godot4 tool to await multiple coroutines, simplifying async task management.

Supported Engine Version
4.1
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
5 months ago
Git URL
Issue URL

Awaiter - Asynchronous Task Manager for Godot

A simple yet powerful asynchronous task management tool for Godot, designed to help you handle asynchronous operations more elegantly.

Features

  • Wait for all tasks to complete (all)
  • Wait for the first task to complete (race)
  • Wait for a specified number of tasks to complete (some)
  • Progress callback for real-time task progress monitoring
  • Supports signals and asynchronous functions

Installation

  1. Copy the addons/awaiter folder into your project.
  2. You're ready to start using it!

DEMO

Check out the demo file: demo.gd

Usage Examples

Awaiter.all - Wait for All Tasks to Complete

Waits for all tasks to complete and returns their results in the order they were completed.

var results = await Awaiter.all([
    async_func1.bind(arg1, arg2), # Pass a Callable
    async_func2.bind(arg1, arg2),
    some_signal # Pass a Signal
])
# Results will be ordered by completion time (first completed task will be first in the array)
print(results) # [result1, result2, result3]

Awaiter.race - Wait for the First Task to Complete

Returns the result of the fastest completing task.

var results = await Awaiter.race([
    task_function.bind("good morning", 1.0),
    task_function.bind("good night", 0.3),
])
print(results) # "good morning"

Awaiter.some - Wait for a Specified Number of Tasks to Complete

Waits for a specified number of tasks to complete and returns their results.

var results = await Awaiter.some([
    task_function.bind("good morning", 1.0),
    task_function.bind("good night", 0.2),
    task_function.bind("good afternoon", 0.1),
    task_function.bind("good noon", 0.5),
], 2)
# Returns an array containing the first 2 completed tasks
print(results) # ["good afternoon", "good night"]

Progress Callback

Provides real-time progress updates as tasks complete.

func progress_callback(completed_count, total):
    print(str(completed_count) + "/" + str(total))

await Awaiter.all({
    "task1": task_function.bind("good morning", 1.0),
    "task2": task_function.bind("good night", 0.2),
}, progress_callback)

Task IDs

Allows you to assign IDs to tasks and retrieve results in a dictionary format.

var results = await Awaiter.all({
    "task1": task_function.bind("good morning", 1.0),
    "task2": task_function.bind("good night", 0.2),
}, progress_callback)
# Results will be a dictionary with task IDs as keys
print(results) # {"task1": "good morning", "task2": "good night"}

This tool simplifies asynchronous task management in Godot, making it easier to handle complex workflows with clean and readable code. Whether you're waiting for multiple tasks, racing them, or monitoring progress, Awaiter has you covered!

A Godot4 tool to await multiple coroutines, simplifying async task management.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Awaiter await-all icon image
Nights
Awaiter await-all

A Godot4 tool to await multiple coroutines, simplifying async task management.

Supported Engine Version
4.1
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
5 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers