How to use a Semaphore when Multithreading in Godot 3

preview_player
Показать описание
In this video I go over what a semaphore is and also how you would use semaphores in Godot Engine to solve the Producer-consumer computing problem.

Timestamps:
0:00 Intro
0:33 Example 1
3:07 Producer-consumer problem
4:40 Example 2
10:15 Outro

Resources:

Рекомендации по теме
Комментарии
Автор

The examples and explanations were very clear. Love this video!!

baowei
Автор

I just found this and i must say you took my projects to another level with your tutorial. Thanks :)

grundxgames
Автор

You just explained the producer consumer problem 10x better than the lecturer did in my Systems Programming class. Keep up the awesome content!!

TheInsidiousTaco
Автор

The timing of this video couldn't have been better. I recently put multithreading into my latest game and although I had a rough idea of semaphore and mutexes, and especially with semaphores, this video made it crystal clear.
Originally I had thought the threads are used in a different way, where one creates them only when necessary and then destroys them, although the uses I'm seeing are creating more threads from the get go, and keeping them alive/waiting/working throughout the entirety of your game loop.

KrystofKlestil
Автор

This could be used to put together a proposal to enhance the existing docs.

sslaxx
Автор

GODOOOWD! Nice tutorial though. godough.

carl-johanhorberg
Автор

Wow! Amazing explanation! Two questions... Why do the consumers and producers wait so long to start consuming/producing (shenanigans) when not using the semaphores? Does it matter if you put the xxx_post() commands inside the mutex.lock/unlock vs. outside (like you have it)?

GregX
Автор

Awesome tutorial.. is these features (threads, semaphore) in Godot work on all platforms (mainly android )?

Paruthi.
Автор

hi

btw just for looks you can change these lines

produce function:
print("producer (", OS.get_thread_caller_id(), ") produced: (", x, ") in buffer at: (", buffer.size(), ")")

consume function:
var x = buffer.front()
buffer.pop_front()
print("consumer (", OS.get_thread_caller_id(), ") consumed: (", x, ") in buffer")

chromiumos
Автор

Maybe you should also make a video about a ringbuffer, which I believe is a better way of solving the Producer/Consumer problem and doesn't require constant locking.

solsticeprojekt
Автор

talking too fast- doesn't give us time to understand what you're saying.

artisanpixel
visit shbcf.ru