mirror of
https://github.com/minetest/minetest.git
synced 2024-09-19 23:10:46 +03:00
fixup! Add questionable workaround for env lock contention
This commit is contained in:
parent
ff16ad52bd
commit
f5e78689d7
@ -127,9 +127,13 @@ void *ServerThread::run()
|
||||
|
||||
u64 t0 = porting::getTimeUs();
|
||||
|
||||
const Server::StepSettings step_settings = m_server->getStepSettings();
|
||||
const auto step_settings = m_server->getStepSettings();
|
||||
|
||||
try {
|
||||
// see explanation inside
|
||||
if (dtime > step_settings.steplen)
|
||||
m_server->yieldToOtherThreads(dtime);
|
||||
|
||||
m_server->AsyncRunStep(step_settings.pause ? 0.0f : dtime);
|
||||
|
||||
const float remaining_time = step_settings.steplen
|
||||
@ -616,9 +620,6 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
||||
if ((dtime == 0.0f) && !initial_step)
|
||||
return;
|
||||
|
||||
// see explanation inside
|
||||
yieldToOtherThreads(dtime);
|
||||
|
||||
ScopeProfiler sp(g_profiler, "Server::AsyncRunStep()", SPT_AVG);
|
||||
|
||||
/*
|
||||
@ -1122,9 +1123,6 @@ void Server::yieldToOtherThreads(float dtime)
|
||||
* queue, thereby avoiding this problem.
|
||||
*/
|
||||
|
||||
if (dtime < getStepSettings().steplen)
|
||||
return;
|
||||
|
||||
// don't activate workaround too quickly
|
||||
constexpr size_t MIN_EMERGE_QUEUE_SIZE = 32;
|
||||
size_t qs = m_emerge->getQueueSize();
|
||||
@ -1136,7 +1134,7 @@ void Server::yieldToOtherThreads(float dtime)
|
||||
const float QUANTUM = 28.0f / 1000;
|
||||
int sleep_count = std::max<int>(1, dtime / QUANTUM);
|
||||
|
||||
ScopeProfiler sp(g_profiler, "Server::yieldToOtherThreads()", SPT_AVG);
|
||||
ScopeProfiler sp(g_profiler, "Server::yieldToOtherThreads() (sum)");
|
||||
while (sleep_count-- > 0) {
|
||||
sleep_ms(1);
|
||||
// abort if we don't make progress
|
||||
|
@ -167,9 +167,12 @@ public:
|
||||
// Actual processing is done in another thread.
|
||||
// This just checks if there was an error in that thread.
|
||||
void step();
|
||||
|
||||
// This is run by ServerThread and does the actual processing
|
||||
void AsyncRunStep(float dtime, bool initial_step = false);
|
||||
void Receive(float timeout);
|
||||
void yieldToOtherThreads(float dtime);
|
||||
|
||||
PlayerSAO* StageTwoClientInit(session_t peer_id);
|
||||
|
||||
/*
|
||||
@ -585,8 +588,6 @@ private:
|
||||
|
||||
void handleChatInterfaceEvent(ChatEvent *evt);
|
||||
|
||||
void yieldToOtherThreads(float dtime);
|
||||
|
||||
// This returns the answer to the sender of wmessage, or "" if there is none
|
||||
std::wstring handleChat(const std::string &name, std::wstring wmessage_input,
|
||||
bool check_shout_priv = false, RemotePlayer *player = nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user