team-phoenix / Phoenix

A multi-system emulator and library manager designed to be both powerful and easy to use.
http://phoenix.vg
GNU General Public License v2.0
377 stars 40 forks source link

Libretro C++ extensions #115

Open athairus opened 9 years ago

athairus commented 9 years ago

It seems clear as I work through the code that in order to have multiple instances of Core, each running in their own thread, we're going to have to do better than using a static pointer to the "latest" instance of Core used. That's not thread-safe.

The biggest issue is that callbacks need to access non-static members of Core, but the callbacks' function signatures do not have a spot for the hidden "this" needed to do this.

Anyway, C++11 provides a way to do callbacks with class functions: http://stackoverflow.com/a/14189561/4190028

Alcaro commented 9 years ago

a static pointer to the "latest" instance of Core used. That's not thread-safe.

With a minor modification, it is.

libretro v2 will contain userdata pointers on the callbacks, but it keeps getting delayed, so I wouldn't recommend waiting.