hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.66k stars 1.16k forks source link

[Q&A] SwapOnVSync can lose order when using multithreading? #1678

Open bluelasers opened 3 months ago

bluelasers commented 3 months ago

Basically the condition wait becomes multi producer to single consumer. I am not sure this works the way you intend. This represents another type of priority inversion in terms of processing order. If one thread gets more time a frame can skip ahead or cause a frame drop. You use async logic without control logic.

bluelasers commented 3 months ago

Note there is a work around on the application side for this. So maybe document and close.

hzeller commented 3 months ago

Frames are emitted in the same order you call SwapOnVSync(), so if you feed from multiple threads and have a particular order in mind you need to order your calls to SwapOnVSync(), which is intended.