Skip to content

Conversation

@CedNaru
Copy link
Member

@CedNaru CedNaru commented Aug 15, 2024

  • Add a new godot.couroutine module.
  • The Gradle plugin can now optionnally include it (and implicitly kotlinx.coroutines)
  • Add a Godot specific scope for coroutines
  • Add an await() functions to all signals that will suspend the coroutines until the signal is emitted.
  • await() can return the signal's arguments, directly (when 1), as a tuple (when 2 and 3), and as list (4+)

I also changed the package of Signal and Callable (I needed them for the await implementation so I took the opportunity).
So far everything has been in the same godot.core package except for those 2. Maybe it's an error and we should split everything into smaller packages but right now I wanted to focus on more consistency.
Note that the await() functions are in the godot.coroutines package as it's not considered the same library.

@CedNaru CedNaru changed the title Add godot-coroutine-library to project Add coroutines await() to signals Aug 15, 2024
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch from 1b3ce84 to f1981cc Compare August 15, 2024 09:05
@CedNaru CedNaru changed the base branch from master to feature/kotlin-lambda-callable August 15, 2024 11:01
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch from f1981cc to ada89ae Compare August 15, 2024 11:04
@piiertho piiertho force-pushed the feature/kotlin-lambda-callable branch 2 times, most recently from 5a448ec to 4f5785c Compare August 21, 2024 06:07
Base automatically changed from feature/kotlin-lambda-callable to master August 21, 2024 10:14
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch from ada89ae to d5f38e7 Compare September 3, 2024 07:54
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch 3 times, most recently from 6cc3d6e to 5db9b2a Compare September 13, 2024 23:39
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch 2 times, most recently from 018d284 to 587e9f3 Compare September 14, 2024 11:56
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch from 587e9f3 to 21283d1 Compare September 14, 2024 12:17
@CedNaru CedNaru force-pushed the feature/godot-coroutine branch from f213992 to f017f4e Compare September 14, 2024 18:07
@CedNaru CedNaru requested a review from chippmann September 14, 2024 18:07
@CedNaru CedNaru requested a review from piiertho September 14, 2024 18:07
@CedNaru CedNaru marked this pull request as ready for review September 14, 2024 18:07
Copy link
Contributor

@chippmann chippmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check that none of the IDE checks are requiring the signals to be in the signal package?

@CedNaru CedNaru linked an issue Sep 18, 2024 that may be closed by this pull request
Copy link
Contributor

@chippmann chippmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What i meant with tests which switch coroutine context is that you await a signal in a test using withContext(Dispatcher.SomeOtherdispatcherThanYouStartedWith) { signal.await() } But that can be added later as well.

Other than that I'm happy :-) Good first implementation with which we can start with and have a look how it feels.

@CedNaru CedNaru merged commit 52892f6 into master Sep 21, 2024
50 checks passed
@CedNaru CedNaru deleted the feature/godot-coroutine branch September 21, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a coroutine context for Godot and its signals.

4 participants