ScummVM API documentation
libretro-threads.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef LIBRETRO_THREADS_H
23#define LIBRETRO_THREADS_H
24
25/* ScummVM doesn't have a top-level main loop that we can use, so instead we run it in its own thread
26 * and switch between it and the main thread. Calling these function will block the current thread
27 * and unblock the other. Each function should be called from the other thread.
28 */
29void retro_switch_to_emu_thread(void);
30void retro_switch_to_main_thread(void);
31
32/* Initialize the emulation thread and any related resources.
33 *
34 * This function should be called from the main thread.
35 */
36bool retro_init_emu_thread(void);
37
38/* Destroy the emulation thread and any related resources. Only call this after the emulation thread
39 * has finished (or canceled) and joined.
40 *
41 * This function should be called from the main thread.
42 */
43void retro_deinit_emu_thread(void);
44
45/* Returns true if the emulation thread was initialized successfully.
46 *
47 * This function should be called from the main thread.
48 */
49bool retro_emu_thread_initialized(void);
50
51/* Returns true if the emulation thread has exited naturally.
52 *
53 * This function can be called from either the main or the emulation thread.
54 */
55bool retro_emu_thread_exited(void);
56
57/* Returns scummvm_main return code or -1 if not available */
58int retro_get_scummvm_res(void);
59
60/* Returns true if the emulation thread was started successfully.
61 *
62 * This function should be called from the main thread.
63 */
64bool retro_emu_thread_started(void);
65
66
67/* Set from the frontend's context_reset (main thread); consumed on the
68 * emulation thread, where the GL context is current, to run the actual
69 * graphics-context reset. */
70void retro_set_context_reset_pending(void);
71bool retro_consume_context_reset(void);
72
73#endif
74