0 votes

I'm currently working on my project on top of the 4.0 branch, and running my simulation on the background using standard C++ threads, and communicating both ways between Godot and my threads using a concurrent queue (https://github.com/cameron314/concurrentqueue). Currently in the middle of a refactoring, I'm beginning to wonder if it wouldn't be smoother to just implement my simulation in one or multiple servers (divided by responsibilities) such as what currently exists for graphics and physics.

I've been investigating the official docs (the Hilbert Hotel example) and the implementation of the visual server, but there are still some details that I'm not understanding, mainly in the server <-> scene tree communication channels.

My main question is: what is the best way to get information from the sceneTree/godot to the server? The Hilbert hotel example functions just lock the conflictive data, and this does not seem very useful if I want to run asynchronously. I'd rather receive the requests through some sort of asynchronous queue, so every server processes information when it sees fit, not through an external locking call. What's the proper way of doing this with servers?

To get information from the server to the sceneTree/godot thread: The recommended way is through the MessageQueue. Any pitfalls that I should avoid here? Or should I use something else?

Probably I'm just missing something obvious here. I'd like to have a clearer picture of the servers communication channels and what do the servers need to implement to support those channels than the documentation currently offers...

PS: How would this server communicate directly with another server without going through the scene tree / gdscript?

Thank you all :D

in Engine by (17 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.