summaryrefslogtreecommitdiff
path: root/cppe/test/Common/TestCommon.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-03-02 09:17:30 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-03-02 09:17:30 +0000
commit2f7037965c40f4d68784f51613d5e9b9a395fcaa (patch)
treef056ed5d9a3e9ed678cc1b43c84e79422307031a /cppe/test/Common/TestCommon.cpp
parentwindows fixes. (diff)
downloadice-2f7037965c40f4d68784f51613d5e9b9a395fcaa.tar.bz2
ice-2f7037965c40f4d68784f51613d5e9b9a395fcaa.tar.xz
ice-2f7037965c40f4d68784f51613d5e9b9a395fcaa.zip
- Fixes for Windows shutdown issue.
- Use a static mutex for the logger.
Diffstat (limited to 'cppe/test/Common/TestCommon.cpp')
-rwxr-xr-xcppe/test/Common/TestCommon.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/cppe/test/Common/TestCommon.cpp b/cppe/test/Common/TestCommon.cpp
index 3d8f03a0dfb..111bc6d5468 100755
--- a/cppe/test/Common/TestCommon.cpp
+++ b/cppe/test/Common/TestCommon.cpp
@@ -20,6 +20,8 @@
using namespace std;
using namespace Ice;
+static IceUtil::StaticMutex globalMutex = ICE_STATIC_MUTEX_INITIALIZER;
+
class LoggerI : public Logger
{
public:
@@ -27,21 +29,23 @@ public:
virtual void
print(const string& message)
{
+ IceUtil::StaticMutex::Lock sync(globalMutex);
tprintf("%s\n", message.c_str());
}
virtual void
trace(const string& category, const string& message)
{
- string s = "[ ";
-#ifdef _WIN32
- {
- char buf[1024];
- sprintf(buf, "%ld", GetTickCount());
- s += buf;
- }
+ IceUtil::StaticMutex::Lock sync(globalMutex);
+ string s = "[ ";
+#ifdef _WIN32
+ {
+ char buf[1024];
+ sprintf(buf, "%ld", GetTickCount());
+ s += buf;
+ }
#else
- s += IceUtil::Time::now().toMilliSeconds();
+ s += IceUtil::Time::now().toMilliSeconds();
#endif
s += ' ';
@@ -63,12 +67,14 @@ public:
virtual void
warning(const string& message)
{
+ IceUtil::StaticMutex::Lock sync(globalMutex);
tprintf("warning: %s\n", message.c_str());
}
virtual void
error(const string& message)
{
+ IceUtil::StaticMutex::Lock sync(globalMutex);
tprintf("error: %s\n", message.c_str());
}
};