Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "implicit conversion changes signedness" errors on Mac_clang #80

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void STDCALL SetResources(
memory.Resize(static_cast<unsigned>(noOfThreads),
DDS_TT_SMALL, THREADMEM_SMALL_DEF_MB, THREADMEM_SMALL_MAX_MB);

threadMgr.Reset(noOfThreads);
threadMgr.Reset(static_cast<unsigned>(noOfThreads));

InitDebugFiles();

Expand Down
26 changes: 13 additions & 13 deletions src/ThreadMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,33 @@ ThreadMgr::~ThreadMgr()
}


void ThreadMgr::Reset(const int nThreads)
void ThreadMgr::Reset(const unsigned int nThreads)
{
if (nThreads > numRealThreads)
{
realThreads.resize(nThreads);
for (int t = numRealThreads; t < nThreads; t++)
for (unsigned int t = numRealThreads; t < nThreads; t++)
realThreads[t] = false;
numRealThreads = nThreads;
}

if (nThreads > numMachineThreads)
{
machineThreads.resize(nThreads);
for (int t = numMachineThreads; t < nThreads; t++)
for (unsigned int t = numMachineThreads; t < nThreads; t++)
machineThreads[t] = -1;
numMachineThreads = nThreads;
}
}


int ThreadMgr::Occupy(const int machineId)
int ThreadMgr::Occupy(const unsigned int machineId)
{
if (machineId >= numMachineThreads)
{
numMachineThreads = machineId + 1;
machineThreads.resize(numMachineThreads);
for (int t = machineId; t < numMachineThreads; t++)
for (unsigned int t = machineId; t < numMachineThreads; t++)
machineThreads[t] = -1;
}

Expand All @@ -75,13 +75,13 @@ int ThreadMgr::Occupy(const int machineId)
do
{
mtx.lock();
for (int t = 0; t < numRealThreads; t++)
for (unsigned int t = 0; t < numRealThreads; t++)
{
if (realThreads[t] == false)
{
realThreads[t] = true;
machineThreads[machineId] = t;
res = t;
machineThreads[machineId] = static_cast<int>(t);
res = static_cast<int>(t);
break;
}
}
Expand All @@ -100,7 +100,7 @@ int ThreadMgr::Occupy(const int machineId)
}


bool ThreadMgr::Release(const int machineId)
bool ThreadMgr::Release(const unsigned int machineId)
{
const int r = machineThreads[machineId];
if (r == -1)
Expand All @@ -109,14 +109,14 @@ bool ThreadMgr::Release(const int machineId)
return false;
}

if (! realThreads[r])
if (! realThreads[static_cast<unsigned int>(r)])
{
// Error: Refers to a real thread that is not in use.
return false;
}

mtx.lock();
realThreads[r] = false;
realThreads[static_cast<unsigned int>(r)] = false;
machineThreads[machineId] = -1;
mtx.unlock();
return true;
Expand All @@ -133,15 +133,15 @@ void ThreadMgr::Print(

fo << tag <<
": Real threads occupied (out of " << numRealThreads << "):\n";
for (int t = 0; t < numRealThreads; t++)
for (unsigned int t = 0; t < numRealThreads; t++)
{
if (realThreads[t])
fo << t << endl;
}
fo << endl;

fo << "Machine threads overview:\n";
for (int t = 0; t < numMachineThreads; t++)
for (unsigned int t = 0; t < numMachineThreads; t++)
{
if (machineThreads[t] != -1)
{
Expand Down
10 changes: 5 additions & 5 deletions src/ThreadMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ class ThreadMgr

vector<bool> realThreads;
vector<int> machineThreads;
int numRealThreads;
int numMachineThreads;
unsigned int numRealThreads;
unsigned int numMachineThreads;

public:

ThreadMgr();

~ThreadMgr();

void Reset(const int nThreads);
void Reset(const unsigned int nThreads);

int Occupy(const int MachineThrId);
int Occupy(const unsigned int MachineThrId);

bool Release(const int MachineThrId);
bool Release(const unsigned int MachineThrId);

void Print(
const string& fname,
Expand Down