Skip to content

Commit fa36391

Browse files
author
Aidan Lee
committed
try recursive mutex for telemetry
1 parent 33ea04d commit fa36391

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/hx/Telemetry.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Telemetry
6363
Stash();
6464

6565
// When a profiler exists, the profiler thread needs to exist
66-
std::lock_guard<std::mutex> lock(gThreadMutex);
66+
std::lock_guard<std::recursive_mutex> lock(gThreadMutex);
6767

6868
gThreadRefCount += 1;
6969
if (gThreadRefCount == 1) {
@@ -73,7 +73,7 @@ class Telemetry
7373

7474
~Telemetry()
7575
{
76-
std::lock_guard<std::mutex> lock(gThreadMutex);
76+
std::lock_guard<std::recursive_mutex> lock(gThreadMutex);
7777

7878
gThreadRefCount -= 1;
7979
}
@@ -144,7 +144,7 @@ class Telemetry
144144
}
145145

146146
{
147-
std::lock_guard<std::mutex> lock(gStashMutex);
147+
std::lock_guard<std::recursive_mutex> lock(gStashMutex);
148148

149149
stashed.push_back(*stash);
150150
}
@@ -154,7 +154,7 @@ class Telemetry
154154

155155
TelemetryFrame* Dump()
156156
{
157-
std::lock_guard<std::mutex> lock(gStashMutex);
157+
std::lock_guard<std::recursive_mutex> lock(gStashMutex);
158158
if (stashed.size()<1) {
159159
return 0;
160160
}
@@ -335,19 +335,19 @@ class Telemetry
335335

336336
std::vector<int> *allocation_data;
337337

338-
static std::mutex gStashMutex;
339-
static std::mutex gThreadMutex;
338+
static std::recursive_mutex gStashMutex;
339+
static std::recursive_mutex gThreadMutex;
340340
static int gThreadRefCount;
341341
static int gProfileClock;
342342

343-
static std::mutex alloc_mutex;
343+
static std::recursive_mutex alloc_mutex;
344344
static std::map<void*, Telemetry*> alloc_map;
345345
};
346-
/* static */ std::mutex Telemetry::gStashMutex;
347-
/* static */ std::mutex Telemetry::gThreadMutex;
346+
/* static */ std::recursive_mutex Telemetry::gStashMutex;
347+
/* static */ std::recursive_mutex Telemetry::gThreadMutex;
348348
/* static */ int Telemetry::gThreadRefCount;
349349
/* static */ int Telemetry::gProfileClock;
350-
/* static */ std::mutex Telemetry::alloc_mutex;
350+
/* static */ std::recursive_mutex Telemetry::alloc_mutex;
351351
/* static */ std::map<void*, Telemetry*> Telemetry::alloc_map;
352352

353353

0 commit comments

Comments
 (0)