Skip to content

Backport of all the multi-threading modernization (3.2)#45618

Merged
hpvb merged 5 commits intogodotengine:3.2from
RandomShaper:modernize_mt_3.2
Feb 18, 2021
Merged

Backport of all the multi-threading modernization (3.2)#45618
hpvb merged 5 commits intogodotengine:3.2from
RandomShaper:modernize_mt_3.2

Conversation

@RandomShaper
Copy link
Copy Markdown
Member

@RandomShaper RandomShaper commented Jan 31, 2021

This a backport of all the multi-threading modernization and enhancements that exist currently for Godot 4.0.

It contains what was already in 4.0 before I started this modernization effort (like Semaphore), plus everything else I've done for that version: Thread, Mutex, atomics, etc.

Benefits:

  • Better portability (former implementations behaved differently across platforms in terms of memory barriers). This is important for 3.2 as it contributes to future-proofing it by clearing the potential maintenance burden of OS-specific implementations of those classes as well as stop relying on the non-standard behavior of volatile that compilers are allowed to stop implementing.
  • Better responsiveness when a thread is waiting for another to finish (to close the editor, etc.).
  • Maybe some hard to reproduce bugs are fixed as a side effect.

UPDATE: I've tested it myself with the TPS demo (going through all the workflow at the editor -importing everything, etc.) and a few other demo projects on Windows and Android.


This code is generously donated by IMVU.

@RandomShaper RandomShaper added this to the 3.2 milestone Jan 31, 2021
@RandomShaper RandomShaper force-pushed the modernize_mt_3.2 branch 8 times, most recently from 2840b5a to 869b4b3 Compare February 1, 2021 17:31
@RandomShaper RandomShaper marked this pull request as ready for review February 1, 2021 20:20
@RandomShaper RandomShaper force-pushed the modernize_mt_3.2 branch 3 times, most recently from e499769 to 55f34a1 Compare February 4, 2021 11:54
- Based on C++14's `shared_time_mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
@Calinou Calinou removed request for a team February 18, 2021 15:05
Copy link
Copy Markdown
Member

@hpvb hpvb left a comment

Choose a reason for hiding this comment

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

We discussed the alignment check, but since this already went into 4.0 I say merge this now. Then do a PR with the checks for both 4.0 and 3.2. Less work that way.

@timothyparez
Copy link
Copy Markdown

This breaks threading in C# again.
Was working fince in 3.2.4-rc2, broken in 3.2.4-rc3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants