Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support lus thread_pool changes #4127

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions soh/soh/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ void SaveManager::SaveSection(int fileNum, int sectionID, bool threaded) {
auto saveContext = new SaveContext;
memcpy(saveContext, &gSaveContext, sizeof(gSaveContext));
if (threaded) {
smThreadPool->push_task_back(&SaveManager::SaveFileThreaded, this, fileNum, saveContext, sectionID);
smThreadPool->detach_task(std::bind(&SaveManager::SaveFileThreaded, this, fileNum, saveContext, sectionID));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from https://github.com/bshoshany/thread-pool/releases/tag/v4.0.0

  • API migration: Use the new names of the functions:
    • push_task() -> detach_task()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API migration: Enclose all tasks with arguments inside a lambda expression. All submitted tasks must have no arguments, but they can still have return values.
Alternatively, std::bind can also be used, if the old syntax is preferred to a lambda. Just wrap it around the task and its arguments: instead of detach_task(task, args...), write detach_task(std::bind(task, args...)). This achieves the same effect, and can be used to easily convert v3.x.x code to v4.0.0

} else {
SaveFileThreaded(fileNum, saveContext, sectionID);
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ void SaveManager::LoadFile(int fileNum) {

void SaveManager::ThreadPoolWait() {
if (smThreadPool) {
smThreadPool->wait_for_tasks();
smThreadPool->wait();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from https://github.com/bshoshany/thread-pool/releases/tag/v4.0.0

  • API migration: Use the new names of the functions:
    • wait_for_tasks() -> wait()

}
}

Expand Down
5 changes: 4 additions & 1 deletion soh/soh/SaveManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ typedef struct {
#include <functional>
#include <vector>
#include <filesystem>
#include "thread-pool/BS_thread_pool.hpp"

#define BS_THREAD_POOL_ENABLE_PRIORITY
#define BS_THREAD_POOL_ENABLE_PAUSE
Comment on lines +43 to +44
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use these in LUS, we get errors if we include the header without them before including it in LUS with them

from https://github.com/bshoshany/thread-pool/releases/tag/v4.0.0

by default, the thread pool is in "light mode". Optional features that may affect performance due to additional checks or more complicated algorithms must be enabled by defining suitable macros before including the library:
BS_THREAD_POOL_ENABLE_PAUSE to enable pausing.
BS_THREAD_POOL_ENABLE_PRIORITY to enable task priority.

#include <BS_thread_pool.hpp>

#include "z64save.h"

Expand Down
Loading