It makes more sense to pass this as a reference, so the plugin cannot do weird things with it.
Implementations for Windows and macOS should be fairly similar, but using the OS' message loop instad of a thread.