Daniele Bartolini 6 rokov pred
rodič
commit
7b7a437ec1

+ 1 - 5
src/core/filesystem/file_monitor_linux.cpp

@@ -112,7 +112,7 @@ struct FileMonitorImpl
 		for (u32 i = 0; i < num; ++i)
 			add_watch(paths[i], recursive);
 
-		_thread.start(run, this);
+		_thread.start([](void* thiz) { return ((FileMonitorImpl*)thiz)->watch(); }, this);
 	}
 
 	void stop()
@@ -323,10 +323,6 @@ struct FileMonitorImpl
 		path::join(path, path_base.c_str(), name);
 	}
 
-	static int run(void* thiz)
-	{
-		return ((FileMonitorImpl*)thiz)->watch();
-	}
 };
 
 FileMonitor::FileMonitor(Allocator& a)

+ 10 - 18
src/device/main_android.cpp

@@ -25,30 +25,15 @@ extern "C"
 
 namespace crown
 {
-static bool s_exit = false;
-
-struct MainThreadArgs
-{
-	DeviceOptions* opts;
-};
-
-s32 func(void* data)
-{
-	MainThreadArgs* args = (MainThreadArgs*)data;
-	crown::run(*args->opts);
-	s_exit = true;
-	return EXIT_SUCCESS;
-}
-
 struct AndroidDevice
 {
 	DeviceEventQueue _queue;
 	Thread _main_thread;
-	MainThreadArgs _margs;
+	DeviceOptions* _opts;
 
 	void run(struct android_app* app, DeviceOptions& opts)
 	{
-		_margs.opts = &opts;
+		_opts = &opts;
 
 		app->userData = this;
 		app->onAppCmd = crown::AndroidDevice::on_app_cmd;
@@ -96,7 +81,14 @@ struct AndroidDevice
 				_queue.push_resolution_event(width, height);
 
 				if (!_main_thread.is_running())
-					_main_thread.start(func, &_margs);
+				{
+					_main_thread.start([](void* user_data) {
+							crown::run(*((DeviceOptions*)user_data));
+							return EXIT_SUCCESS;
+						}
+						, _opts
+						);
+				}
 			}
 			break;
 

+ 7 - 18
src/device/main_linux.cpp

@@ -295,20 +295,6 @@ struct Joypad
 };
 
 static bool s_exit = false;
-
-struct MainThreadArgs
-{
-	DeviceOptions* opts;
-};
-
-s32 func(void* data)
-{
-	MainThreadArgs* args = (MainThreadArgs*)data;
-	crown::run(*args->opts);
-	s_exit = true;
-	return EXIT_SUCCESS;
-}
-
 static Cursor _x11_cursors[MouseCursor::COUNT];
 
 struct LinuxDevice
@@ -402,11 +388,14 @@ struct LinuxDevice
 		_x11_cursors[MouseCursor::WAIT]                = XCreateFontCursor(_x11_display, XC_watch);
 
 		// Start main thread
-		MainThreadArgs mta;
-		mta.opts = opts;
-
 		Thread main_thread;
-		main_thread.start(func, &mta);
+		main_thread.start([](void* user_data) {
+				crown::run(*((DeviceOptions*)user_data));
+				s_exit = true;
+				return EXIT_SUCCESS;
+			}
+			, opts
+			);
 
 		_joypad.init();
 

+ 7 - 18
src/device/main_windows.cpp

@@ -283,20 +283,6 @@ struct Joypad
 };
 
 static bool s_exit = false;
-
-struct MainThreadArgs
-{
-	DeviceOptions* opts;
-};
-
-s32 func(void* data)
-{
-	MainThreadArgs* args = (MainThreadArgs*)data;
-	crown::run(*args->opts);
-	s_exit = true;
-	return EXIT_SUCCESS;
-}
-
 static HCURSOR _win_cursors[MouseCursor::COUNT];
 
 struct WindowsDevice
@@ -314,9 +300,6 @@ struct WindowsDevice
 
 	int	run(DeviceOptions* opts)
 	{
-		MainThreadArgs mta;
-		mta.opts = opts;
-
 		HINSTANCE instance = (HINSTANCE)GetModuleHandle(NULL);
 		WNDCLASSEX wnd;
 		memset(&wnd, 0, sizeof(wnd));
@@ -367,7 +350,13 @@ struct WindowsDevice
 		_win_cursors[MouseCursor::WAIT]                = LoadCursorA(NULL, IDC_WAIT);
 
 		Thread main_thread;
-		main_thread.start(func, &mta);
+		main_thread.start([](void* user_data) {
+				crown::run(*((DeviceOptions*)user_data));
+				s_exit = true;
+				return EXIT_SUCCESS;
+			}
+			, opts
+			);
 
 		MSG msg;
 		msg.message = WM_NULL;

+ 1 - 6
src/resource/resource_loader.cpp

@@ -22,11 +22,6 @@ LOG_SYSTEM(RESOURCE_LOADER, "resource_loader")
 
 namespace crown
 {
-static s32 thread_proc(void* thiz)
-{
-	return ((ResourceLoader*)thiz)->run();
-}
-
 ResourceLoader::ResourceLoader(Filesystem& data_filesystem)
 	: _data_filesystem(data_filesystem)
 	, _requests(default_allocator())
@@ -34,7 +29,7 @@ ResourceLoader::ResourceLoader(Filesystem& data_filesystem)
 	, _fallback(default_allocator())
 	, _exit(false)
 {
-	_thread.start(thread_proc, this);
+	_thread.start([](void* thiz) { return ((ResourceLoader*)thiz)->run(); }, this);
 }
 
 ResourceLoader::~ResourceLoader()