Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
532 stars 140 forks source link

Unlock ruby global lock during graphics ops #242

Closed vmedea closed 3 years ago

vmedea commented 3 years ago

Unlock the ruby global lock during potentially blocking graphics ops. This enables using multithreading using ruby's thread extension.

I don't actually know if this patch makes sense here, I do not know if the original RPG Maker has any concept of this, but had some use for this myself in combination with socket to remotely poke into a game, and wanted to put it out somewhere in case it's useful for someone. Feel free to close.

Ancurio commented 3 years ago

Could you try and see whether your use case is covered by mkxp-z? Quoting the main dev,

Right now mkxp-z is set up so that (A) graphics functions always make sure that the current thread is the one that the GL context is set to, so you can call them from things other than the main thread, (B) all graphics functions themselves are synced to their own lock so that they don't trample over each other, and (C) Graphics.update and any other non-graphics-related functions that take a lot of time are taken off the GVL so that other threads aren't blocked by them

vmedea commented 3 years ago

(C) Graphics.update and any other non-graphics-related functions that take a lot of time are taken off the GVL so that other threads aren't blocked by them

Right, yes, this is exactly what I did. I should probably have looked closer at that project.