This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Add hooks for setting experimental thread priorities for mbgl …
…threads
- Loading branch information
1 parent
755c9f1
commit bf9e2b6
Showing
11 changed files
with
99 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <mbgl/platform/settings.hpp> | ||
#include <mbgl/util/platform.hpp> | ||
|
||
namespace mbgl { | ||
namespace util { | ||
|
||
// Thread priority strategies | ||
// | ||
// ThreadPrioritySetterLow: Sets thread priority to low. Platform must set | ||
// correct thread priority via implementing platform::makeThreadLowPriority() | ||
// | ||
// ThreadPrioritySetterCustom: Sets thread priority for a thread type based on | ||
// a setting platform::EXPERIMENTAL_THREAD_PRIORITY_* for a provided thread type. | ||
|
||
struct ThreadPrioritySetter {}; | ||
|
||
struct ThreadPrioritySetterLow final : public ThreadPrioritySetter { | ||
void setThreadPriority() { platform::makeThreadLowPriority(); } | ||
}; | ||
|
||
struct ThreadPrioritySetterCustom final : public ThreadPrioritySetter { | ||
ThreadPrioritySetterCustom(std::string threadType_) : threadType(std::move(threadType_)) {} | ||
void setThreadPriority() { | ||
auto& settings = platform::Settings::getInstance(); | ||
auto value = settings.get(threadType); | ||
if (auto* priority = value.getDouble()) { | ||
platform::setCurrentThreadPriority(*priority); | ||
} else { | ||
platform::makeThreadLowPriority(); | ||
} | ||
} | ||
std::string threadType; | ||
}; | ||
|
||
} // namespace util | ||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters