Rootex icon indicating copy to clipboard operation
Rootex copied to clipboard

Threadpool assigns work to the main thread if only 1 task is submitted

Open twaritwaikar opened this issue 5 years ago • 0 comments

    ThreadPool& preloadThreads = Application::GetSingleton()->getThreadPool();
	Vector<Ref<Task>> preloadTasks;

	progress = 1;
	for (auto& path : empericalPaths)
	{
		Ref<Task> loadingTask(new Task([=, &progress]() {
			CreateSomeResourceFile(path);
			progress++;
		}));
		preloadTasks.push_back(loadingTask);
	}

	preloadTasks.push_back(Ref<Task>(new Task([]() {})));

	preloadThreads.submit(preloadTasks);

We currently have to add a dummy task to get around this

twaritwaikar avatar Sep 08 '20 09:09 twaritwaikar