Skip to content

Commit 885879e

Browse files
authored
Move MethodContextReader to use the minipal mutex (#117685)
1 parent 05e00fc commit 885879e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/coreclr/tools/superpmi/superpmi-shared/methodcontextreader.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ MethodContextReader::MethodContextReader(
9494
, Offset(offset)
9595
, Increment(increment)
9696
{
97-
this->mutex = CreateMutexW(NULL, FALSE, nullptr);
97+
minipal_mutex_init(&this->mutex);
9898

9999
std::string tocFileName, mchFileName;
100100

@@ -140,20 +140,19 @@ MethodContextReader::~MethodContextReader()
140140
CloseHandle(this->fileHandle);
141141
}
142142

143-
CloseHandle(this->mutex);
144-
143+
minipal_mutex_destroy(&this->mutex);
145144
CleanExcludedMethods();
146145
}
147146

148147
bool MethodContextReader::AcquireLock()
149148
{
150-
DWORD res = WaitForSingleObject(this->mutex, INFINITE);
151-
return (res == WAIT_OBJECT_0);
149+
minipal_mutex_enter(&this->mutex);
150+
return true;
152151
}
153152

154153
void MethodContextReader::ReleaseLock()
155154
{
156-
ReleaseMutex(this->mutex);
155+
minipal_mutex_leave(&this->mutex);
157156
}
158157

159158
bool MethodContextReader::atEof()
@@ -418,7 +417,7 @@ bool MethodContextReader::hasTOC()
418417

419418
bool MethodContextReader::isValid()
420419
{
421-
return this->fileHandle != INVALID_HANDLE_VALUE && this->mutex != INVALID_HANDLE_VALUE;
420+
return this->fileHandle != INVALID_HANDLE_VALUE;
422421
}
423422

424423
// Return a measure of "progress" through the method contexts, as follows:
@@ -640,7 +639,7 @@ void MethodContextReader::Reset(const int* newIndexes, int newIndexCount)
640639
int64_t pos = 0;
641640
BOOL result = SetFilePointerEx(fileHandle, *(PLARGE_INTEGER)&pos, NULL, FILE_BEGIN);
642641
assert(result);
643-
642+
644643
Indexes = newIndexes;
645644
IndexCount = newIndexCount;
646645
curIndexPos = 0;

src/coreclr/tools/superpmi/superpmi-shared/methodcontextreader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "methodcontext.h"
1212
#include "tocfile.h"
13+
#include <minipal/mutex.h>
1314

1415
struct MethodContextBuffer
1516
{
@@ -56,7 +57,7 @@ class MethodContextReader
5657
int curMCIndex;
5758

5859
// The synchronization mutex
59-
HANDLE mutex;
60+
minipal_mutex mutex;
6061
bool AcquireLock();
6162
void ReleaseLock();
6263

0 commit comments

Comments
 (0)