mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
Warn if async engine seems stuck (#16010)
This commit is contained in:
parent
60c47c51e0
commit
bdaabad53c
2 changed files with 59 additions and 11 deletions
|
@ -138,6 +138,11 @@ protected:
|
|||
*/
|
||||
void stepAutoscale();
|
||||
|
||||
/**
|
||||
* Print warning message if too many jobs are stuck
|
||||
*/
|
||||
void stepStuckWarning();
|
||||
|
||||
/**
|
||||
* Initialize environment with current registred functions
|
||||
* this function adds all functions registred by registerFunction to the
|
||||
|
@ -149,6 +154,21 @@ protected:
|
|||
bool prepareEnvironment(lua_State* L, int top);
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
inline void snapshotJobs(T &to)
|
||||
{
|
||||
for (const auto &it : jobQueue)
|
||||
to.emplace(it.id);
|
||||
}
|
||||
template <typename T>
|
||||
inline size_t compareJobs(const T &from)
|
||||
{
|
||||
size_t overlap = 0;
|
||||
for (const auto &it : jobQueue)
|
||||
overlap += from.count(it.id);
|
||||
return overlap;
|
||||
}
|
||||
|
||||
// Variable locking the engine against further modification
|
||||
bool initDone = false;
|
||||
|
||||
|
@ -158,6 +178,9 @@ private:
|
|||
u64 autoscaleTimer = 0;
|
||||
std::unordered_set<u32> autoscaleSeenJobs;
|
||||
|
||||
u64 stuckTimer = 0;
|
||||
std::unordered_set<u32> stuckSeenJobs;
|
||||
|
||||
// Only set for the server async environment (duh)
|
||||
Server *server = nullptr;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue