Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ MethodContextReader::MethodContextReader(
, Offset(offset)
, Increment(increment)
{
this->mutex = CreateMutexW(NULL, FALSE, nullptr);
minipal_mutex_init(&this->mutex);

std::string tocFileName, mchFileName;

Expand Down Expand Up @@ -140,20 +140,19 @@ MethodContextReader::~MethodContextReader()
CloseHandle(this->fileHandle);
}

CloseHandle(this->mutex);

minipal_mutex_destroy(&this->mutex);
CleanExcludedMethods();
}

bool MethodContextReader::AcquireLock()
{
DWORD res = WaitForSingleObject(this->mutex, INFINITE);
return (res == WAIT_OBJECT_0);
minipal_mutex_enter(&this->mutex);
return true;
}

void MethodContextReader::ReleaseLock()
{
ReleaseMutex(this->mutex);
minipal_mutex_leave(&this->mutex);
}

bool MethodContextReader::atEof()
Expand Down Expand Up @@ -418,7 +417,7 @@ bool MethodContextReader::hasTOC()

bool MethodContextReader::isValid()
{
return this->fileHandle != INVALID_HANDLE_VALUE && this->mutex != INVALID_HANDLE_VALUE;
return this->fileHandle != INVALID_HANDLE_VALUE;
}

// Return a measure of "progress" through the method contexts, as follows:
Expand Down Expand Up @@ -640,7 +639,7 @@ void MethodContextReader::Reset(const int* newIndexes, int newIndexCount)
int64_t pos = 0;
BOOL result = SetFilePointerEx(fileHandle, *(PLARGE_INTEGER)&pos, NULL, FILE_BEGIN);
assert(result);

Indexes = newIndexes;
IndexCount = newIndexCount;
curIndexPos = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "methodcontext.h"
#include "tocfile.h"
#include <minipal/mutex.h>

struct MethodContextBuffer
{
Expand Down Expand Up @@ -56,7 +57,7 @@ class MethodContextReader
int curMCIndex;

// The synchronization mutex
HANDLE mutex;
minipal_mutex mutex;
bool AcquireLock();
void ReleaseLock();

Expand Down
Loading