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

Conversation

briaguya-ai
Copy link
Contributor

@briaguya-ai briaguya-ai commented May 7, 2024

@@ -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

@@ -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()

Comment on lines +43 to +44
#define BS_THREAD_POOL_ENABLE_PRIORITY
#define BS_THREAD_POOL_ENABLE_PAUSE
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.

@briaguya-ai briaguya-ai merged commit 52fad95 into HarbourMasters:develop May 7, 2024
6 checks passed
briaguya-ai added a commit to briaguya-ai/Shipwright that referenced this pull request May 9, 2024
@briaguya-ai briaguya-ai deleted the support-lus-thread_pool-changes branch January 3, 2025 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants