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

Remove MutexPtrLock usage from Slice compilers #1705

Merged
merged 1 commit into from
Jan 22, 2024
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
30 changes: 5 additions & 25 deletions cpp/src/ice2slice/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,30 @@

#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/ConsoleUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
#include <Gen.h>

#include <mutex>

using namespace std;
using namespace Slice;
using namespace IceUtilInternal;

namespace
{

IceUtil::Mutex* globalMutex = 0;
mutex globalMutex;
bool interrupted = false;

class Init
{
public:

Init()
{
globalMutex = new IceUtil::Mutex;
}

~Init()
{
delete globalMutex;
globalMutex = 0;
}
};

Init init;

}

void
interruptedCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
interrupted = true;
}

Expand Down Expand Up @@ -237,8 +218,7 @@ compile(const vector<string>& argv)
++i;

{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
if(interrupted)
{
FileTracker::instance()->cleanup();
Expand Down
30 changes: 5 additions & 25 deletions cpp/src/slice2cpp/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,31 @@

#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/ConsoleUtil.h>

#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
#include "Gen.h"

#include <mutex>

using namespace std;
using namespace Slice;
using namespace IceUtilInternal;

namespace
{

IceUtil::Mutex* globalMutex = 0;
mutex globalMutex;
bool interrupted = false;

class Init
{
public:

Init()
{
globalMutex = new IceUtil::Mutex;
}

~Init()
{
delete globalMutex;
globalMutex = 0;
}
};

Init init;

}

void
interruptedCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
interrupted = true;
}

Expand Down Expand Up @@ -340,8 +321,7 @@ compile(const vector<string>& argv)
}

{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
if(interrupted)
{
FileTracker::instance()->cleanup();
Expand Down
30 changes: 5 additions & 25 deletions cpp/src/slice2cs/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,30 @@

#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/ConsoleUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
#include "Gen.h"

#include <mutex>

using namespace std;
using namespace Slice;
using namespace IceUtilInternal;

namespace
{

IceUtil::Mutex* globalMutex = 0;
mutex globalMutex;
bool interrupted = false;

class Init
{
public:

Init()
{
globalMutex = new IceUtil::Mutex;
}

~Init()
{
delete globalMutex;
globalMutex = 0;
}
};

Init init;

}

void
interruptedCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
interrupted = true;
}

Expand Down Expand Up @@ -317,8 +298,7 @@ compile(const vector<string>& argv)
}

{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
if(interrupted)
{
FileTracker::instance()->cleanup();
Expand Down
33 changes: 5 additions & 28 deletions cpp/src/slice2java/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/ConsoleUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
#include <Gen.h>

#include <iterator>
#include <mutex>

using namespace std;
using namespace Slice;
Expand All @@ -20,34 +20,15 @@ using namespace IceUtilInternal;
namespace
{

IceUtil::Mutex* globalMutex = 0;
mutex globalMutex;
bool interrupted = false;

class Init
{
public:

Init()
{
globalMutex = new IceUtil::Mutex;
}

~Init()
{
delete globalMutex;
globalMutex = 0;
}
};

Init init;

}

void
interruptedCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
interrupted = true;
}

Expand Down Expand Up @@ -316,13 +297,9 @@ compile(const vector<string>& argv)
}

{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
if(interrupted)
{
//
// If the translator was interrupted then cleanup any files we've already created.
//
FileTracker::instance()->cleanup();
return EXIT_FAILURE;
}
Expand Down
30 changes: 5 additions & 25 deletions cpp/src/slice2js/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,30 @@

#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/ConsoleUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Util.h>
#include <Gen.h>

#include <mutex>

using namespace std;
using namespace Slice;
using namespace IceUtilInternal;

namespace
{

IceUtil::Mutex* globalMutex = 0;
mutex globalMutex;
bool interrupted = false;

class Init
{
public:

Init()
{
globalMutex = new IceUtil::Mutex;
}

~Init()
{
delete globalMutex;
globalMutex = 0;
}
};

Init init;

}

void
interruptedCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
interrupted = true;
}

Expand Down Expand Up @@ -367,8 +348,7 @@ compile(const vector<string>& argv)
}

{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
if(interrupted)
{
FileTracker::instance()->cleanup();
Expand Down
30 changes: 5 additions & 25 deletions cpp/src/slice2matlab/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
#include <IceUtil/Options.h>
#include <IceUtil/OutputUtil.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <IceUtil/ConsoleUtil.h>
#include <IceUtil/FileUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/FileTracker.h>
#include <Slice/Parser.h>
#include <Slice/Util.h>

#include <cstring>
#include <climits>
#include <iterator>
#include <mutex>

#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -4503,34 +4503,15 @@ CodeVisitor::writeBaseClassArrayParams(IceUtilInternal::Output& out, const Membe
namespace
{

IceUtil::Mutex* globalMutex = 0;
mutex globalMutex;
bool interrupted = false;

class Init
{
public:

Init()
{
globalMutex = new IceUtil::Mutex;
}

~Init()
{
delete globalMutex;
globalMutex = 0;
}
};

Init init;

}

static void
interruptedCallback(int /*signal*/)
{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
interrupted = true;
}

Expand Down Expand Up @@ -4793,8 +4774,7 @@ compile(const vector<string>& argv)
}

{
IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);

lock_guard lock(globalMutex);
if(interrupted)
{
FileTracker::instance()->cleanup();
Expand Down
Loading