summaryrefslogtreecommitdiff
path: root/retro_emu_thread.h
diff options
context:
space:
mode:
authorAutechre2020-10-23 17:34:42 +0200
committerGitHub2020-10-23 17:34:42 +0200
commitf5eae17f5ac35b5d2cbbbb6388ca5ef23b12ef66 (patch)
treea5df0ee083892fad6e8f878deb69d3cf1d8060b8 /retro_emu_thread.h
parente5bb2ffdd21ef83baf15152969e36dcf23bf80f1 (diff)
parent2b189fe810bc97baf3aa46999bfb731a558de580 (diff)
downloadpicogpsp-f5eae17f5ac35b5d2cbbbb6388ca5ef23b12ef66.tar.gz
picogpsp-f5eae17f5ac35b5d2cbbbb6388ca5ef23b12ef66.tar.bz2
picogpsp-f5eae17f5ac35b5d2cbbbb6388ca5ef23b12ef66.zip
Merge pull request #81 from jdgleaver/libco-alt
Add build-time option to run the emulator in a thread instead of libco (fixes OpenDingux target)
Diffstat (limited to 'retro_emu_thread.h')
-rw-r--r--retro_emu_thread.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/retro_emu_thread.h b/retro_emu_thread.h
new file mode 100644
index 0000000..472ae8b
--- /dev/null
+++ b/retro_emu_thread.h
@@ -0,0 +1,51 @@
+#ifndef EMU_THREAD_H
+#define EMU_THREAD_H
+
+#include "common.h"
+
+/* gpSP doesn't have a top-level main loop that we can use, so instead we run it in its own thread
+ * and switch between it and the main thread. Calling this function will block the current thread
+ * and unblock the other.
+ *
+ * This function can be called from either the main or the emulation thread.
+ */
+void retro_switch_thread(void);
+
+/* Initialize the emulation thread and any related resources.
+ *
+ * Only call this function from the main thread.
+ */
+bool retro_init_emu_thread(bool dynarec, u32 cycles);
+
+/* Destroy the emulation thread and any related resources. Only call this after the emulation thread
+ * has finished (or canceled) and joined.
+ *
+ * Only call this function from the main thread.
+ */
+void retro_deinit_emu_thread(void);
+
+/* Returns true if the emulation thread was initialized successfully.
+ *
+ * This function can be called from either the main or the emulation thread.
+ */
+bool retro_is_emu_thread_initialized(void);
+
+/* Join the emulation thread. The thread must have exited naturally or been canceled.
+ *
+ * Only call this function from the main thread.
+ */
+void retro_join_emu_thread(void);
+
+/* Cancel the emulation thread.
+ *
+ * Only call this function from the main thread.
+ */
+void retro_cancel_emu_thread(void);
+
+/* Returns true if the emulation thread has exited naturally.
+ *
+ * This function can be called from either the main or the emulation thread.
+ */
+bool retro_emu_thread_exited(void);
+
+#endif