summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2009-04-24 13:55:37 -0230
committerDwayne Boone <dwayne@zeroc.com>2009-04-24 13:55:37 -0230
commitb7781c854fc8dc9c02f8abe363c46b8f4f28e859 (patch)
tree4915ec5588dc04bc8f7f99740d1062e4a1898296 /cpp/src/IceUtil
parentBug 3811 - unsubstitued verion strings in READMES (diff)
downloadice-b7781c854fc8dc9c02f8abe363c46b8f4f28e859.tar.bz2
ice-b7781c854fc8dc9c02f8abe363c46b8f4f28e859.tar.xz
ice-b7781c854fc8dc9c02f8abe363c46b8f4f28e859.zip
Bug 2812 - add abilty to name thread
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r--cpp/src/IceUtil/Thread.cpp36
-rw-r--r--cpp/src/IceUtil/Timer.cpp4
2 files changed, 39 insertions, 1 deletions
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp
index c04f6c07c33..37af697dbb9 100644
--- a/cpp/src/IceUtil/Thread.cpp
+++ b/cpp/src/IceUtil/Thread.cpp
@@ -112,6 +112,15 @@ IceUtil::Thread::Thread() :
{
}
+IceUtil::Thread::Thread(const string& name) :
+ _name(name),
+ _started(false),
+ _running(false),
+ _handle(0),
+ _id(0)
+{
+}
+
IceUtil::Thread::~Thread()
{
}
@@ -151,6 +160,10 @@ WINAPI startHook(void* arg)
}
catch(...)
{
+ if(!thread->name().empty())
+ {
+ cerr << thread->name() << " terminating" << endl;
+ }
#if defined(_MSC_VER) && (_MSC_VER < 1300)
terminate();
#else
@@ -255,6 +268,12 @@ IceUtil::Thread::_done()
_running = false;
}
+const string&
+IceUtil::Thread::name() const
+{
+ return _name;
+}
+
#else
IceUtil::ThreadControl::ThreadControl(pthread_t thread) :
@@ -340,6 +359,13 @@ IceUtil::Thread::Thread() :
{
}
+IceUtil::Thread::Thread(const string& name) :
+ _name(name),
+ _started(false),
+ _running(false)
+{
+}
+
IceUtil::Thread::~Thread()
{
}
@@ -369,6 +395,10 @@ startHook(void* arg)
}
catch(...)
{
+ if(!thread->name().empty())
+ {
+ cerr << thread->name() << " terminating" << endl;
+ }
std::terminate();
}
@@ -495,4 +525,10 @@ IceUtil::Thread::_done()
_running = false;
}
+const string&
+IceUtil::Thread::name() const
+{
+ return _name;
+}
+
#endif
diff --git a/cpp/src/IceUtil/Timer.cpp b/cpp/src/IceUtil/Timer.cpp
index 7416895b050..41200f5648b 100644
--- a/cpp/src/IceUtil/Timer.cpp
+++ b/cpp/src/IceUtil/Timer.cpp
@@ -13,7 +13,9 @@
using namespace std;
using namespace IceUtil;
-Timer::Timer() : _destroyed(false)
+Timer::Timer() :
+ Thread("IceUtil timer thread"),
+ _destroyed(false)
{
__setNoDelete(true);
start();