summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Thread.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2012-07-13 00:18:06 +0200
committerJose <jose@zeroc.com>2012-07-13 00:18:06 +0200
commit70802b63320582f0afa8229659ea9fe4a21d02ec (patch)
treeeb455947cc774cc558f96b8d7c78373d2a6f1c2b /cpp/src/IceUtil/Thread.cpp
parentICE-4839 - Glacier2 sessionHelper IceSSL plug-in (diff)
downloadice-70802b63320582f0afa8229659ea9fe4a21d02ec.tar.bz2
ice-70802b63320582f0afa8229659ea9fe4a21d02ec.tar.xz
ice-70802b63320582f0afa8229659ea9fe4a21d02ec.zip
WinRT support
Diffstat (limited to 'cpp/src/IceUtil/Thread.cpp')
-rw-r--r--cpp/src/IceUtil/Thread.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp
index 8e4fd2303a0..a629586a43b 100644
--- a/cpp/src/IceUtil/Thread.cpp
+++ b/cpp/src/IceUtil/Thread.cpp
@@ -63,7 +63,11 @@ IceUtil::ThreadControl::join()
throw BadThreadControlException(__FILE__, __LINE__);
}
+#ifndef ICE_OS_WINRT
DWORD rc = WaitForSingleObject(_handle, INFINITE);
+#else
+ DWORD rc = WaitForSingleObjectEx(_handle, INFINITE, true);
+#endif
if(rc != WAIT_OBJECT_0)
{
throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
@@ -95,7 +99,11 @@ IceUtil::ThreadControl::id() const
void
IceUtil::ThreadControl::sleep(const Time& timeout)
{
+#ifndef ICE_OS_WINRT
Sleep(static_cast<long>(timeout.toMilliSeconds()));
+#else
+ WaitForSingleObjectEx(GetCurrentThread(), static_cast<long>(timeout.toMilliSeconds()), true);
+#endif
}
void
@@ -106,7 +114,11 @@ IceUtil::ThreadControl::yield()
// of its time slice to any other thread of equal priority that is
// ready to run.
//
+#ifndef ICE_OS_WINRT
Sleep(0);
+#else
+ WaitForSingleObjectEx(GetCurrentThread(), 0, true);
+#endif
}
IceUtil::Thread::Thread() :
@@ -172,7 +184,7 @@ WINAPI startHook(void* arg)
#if defined(_MSC_VER) && (_MSC_VER < 1300)
terminate();
#else
- std::terminate();
+ std::terminate();
#endif
}
@@ -220,14 +232,21 @@ IceUtil::Thread::start(size_t stackSize, int priority)
reinterpret_cast<HANDLE>(
_beginthreadex(0,
static_cast<unsigned int>(stackSize),
- startHook, this, CREATE_SUSPENDED, &id));
+ startHook, this,
+#ifndef ICE_OS_WINRT
+ CREATE_SUSPENDED,
+#else
+ 0,
+#endif
+ &id));
_id = id;
-
+ assert(_handle != (HANDLE)-1L);
if(_handle == 0)
{
__decRef();
throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
+#ifndef ICE_OS_WINRT
if(SetThreadPriority(_handle, priority) == 0)
{
throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
@@ -237,6 +256,7 @@ IceUtil::Thread::start(size_t stackSize, int priority)
__decRef();
throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
+#endif
_started = true;
_running = true;