diff options
Diffstat (limited to 'cpp/src/Ice/ThreadPool.cpp')
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 7d95c48b2b5..bbd8b49d087 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -110,6 +110,29 @@ class ThreadPoolDestroyedException { }; +#ifdef ICE_SWIFT +string +prefixToDispatchQueueLabel(const std::string& prefix) +{ + if(prefix == "Ice.ThreadPool.Client") + { + return "com.zeroc.ice.client"; + } + + if(prefix == "Ice.ThreadPool.Server") + { + return "com.zeroc.ice.server"; + } + + string::size_type end = prefix.find_last_of(".ThreadPool"); + if(end == string::npos) + { + end = prefix.size(); + } + + return "com.zeroc.ice.oa." + prefix.substr(0, end); +} +#endif } Ice::DispatcherCall::~DispatcherCall() @@ -245,7 +268,11 @@ IceInternal::ThreadPoolWorkQueue::getNativeInfo() IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& prefix, int timeout) : _instance(instance), +#ifdef ICE_SWIFT + _dispatchQueue(dispatch_queue_create(prefixToDispatchQueueLabel(prefix).c_str(), DISPATCH_QUEUE_CONCURRENT)), +#else _dispatcher(_instance->initializationData().dispatcher), +#endif _destroyed(false), _prefix(prefix), _selector(instance), @@ -429,6 +456,9 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p IceInternal::ThreadPool::~ThreadPool() { assert(_destroyed); +#ifdef ICE_SWIFT + dispatch_release(_dispatchQueue); +#endif } void @@ -543,6 +573,12 @@ IceInternal::ThreadPool::ready(const EventHandlerPtr& handler, SocketOperation o void IceInternal::ThreadPool::dispatchFromThisThread(const DispatchWorkItemPtr& workItem) { +#ifdef ICE_SWIFT + dispatch_sync(_dispatchQueue, ^ + { + workItem->run(); + }); +#else if(_dispatcher) { try @@ -578,6 +614,7 @@ IceInternal::ThreadPool::dispatchFromThisThread(const DispatchWorkItemPtr& workI { workItem->run(); } +#endif } void @@ -615,6 +652,16 @@ IceInternal::ThreadPool::prefix() const return _prefix; } +#ifdef ICE_SWIFT + +dispatch_queue_t +IceInternal::ThreadPool::getDispatchQueue() const ICE_NOEXCEPT +{ + return _dispatchQueue; +} + +#endif + void IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread) { |