mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-24 21:35:40 +00:00
Restore recursive locking for mutexes converted from CRITICAL_SECTION
CRITICAL_SECTION is reentrant; std::mutex is not. This caused deadlocks during world generation, post-processing, and saving.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "ProgressRenderer.h"
|
||||
#include "../../../Minecraft.World/Platform/System.h"
|
||||
|
||||
std::mutex ProgressRenderer::s_progress;
|
||||
std::recursive_mutex ProgressRenderer::s_progress;
|
||||
|
||||
ProgressRenderer::ProgressRenderer(Minecraft* minecraft) {
|
||||
status = -1;
|
||||
@@ -34,7 +34,7 @@ void ProgressRenderer::_progressStart(int title) {
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
lastPercent = 0;
|
||||
this->title = title;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ void ProgressRenderer::progressStage(int status) {
|
||||
|
||||
lastTime = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
m_eType = eProgressStringType_ID;
|
||||
this->status = status;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ void ProgressRenderer::progressStagePercentage(int i) {
|
||||
// 4J Stu - Removing all progressRenderer rendering. This will be replaced
|
||||
// on the xbox
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
lastPercent = i;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void ProgressRenderer::progressStagePercentage(int i) {
|
||||
int ProgressRenderer::getCurrentPercent() {
|
||||
int returnValue = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
returnValue = lastPercent;
|
||||
}
|
||||
return returnValue;
|
||||
@@ -77,7 +77,7 @@ int ProgressRenderer::getCurrentPercent() {
|
||||
int ProgressRenderer::getCurrentTitle() {
|
||||
int returnValue;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
returnValue = title;
|
||||
}
|
||||
return returnValue;
|
||||
@@ -86,7 +86,7 @@ int ProgressRenderer::getCurrentTitle() {
|
||||
int ProgressRenderer::getCurrentStatus() {
|
||||
int returnValue;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
returnValue = status;
|
||||
}
|
||||
return returnValue;
|
||||
@@ -95,25 +95,25 @@ int ProgressRenderer::getCurrentStatus() {
|
||||
ProgressRenderer::eProgressStringType ProgressRenderer::getType() {
|
||||
eProgressStringType returnValue;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
returnValue = m_eType;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void ProgressRenderer::setType(eProgressStringType eType) {
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
m_eType = eType;
|
||||
}
|
||||
|
||||
void ProgressRenderer::progressStage(std::wstring& wstrText) {
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
m_wstrText = wstrText;
|
||||
m_eType = eProgressStringType_String;
|
||||
}
|
||||
|
||||
std::wstring& ProgressRenderer::getProgressString(void) {
|
||||
std::lock_guard<std::mutex> lock(ProgressRenderer::s_progress);
|
||||
std::lock_guard<std::recursive_mutex> lock(ProgressRenderer::s_progress);
|
||||
std::wstring& temp = m_wstrText;
|
||||
return temp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user