summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2019-05-07 10:51:58 -0400
committerJoe George <joe@zeroc.com>2019-05-07 11:12:17 -0400
commit0199db0b81df4a37fe63069a9fc75e13d880e967 (patch)
tree48901929000d768d85f0eb350c60e99e962e4d38
parentRegenerate Xcode projects (diff)
downloadice-0199db0b81df4a37fe63069a9fc75e13d880e967.tar.bz2
ice-0199db0b81df4a37fe63069a9fc75e13d880e967.tar.xz
ice-0199db0b81df4a37fe63069a9fc75e13d880e967.zip
Dispatch queue updates
- Remove dispatch queues from Swift APIs - Create dispatch queue in C++ thread pool (ICE_SWIFT only)
-rw-r--r--cpp/include/Ice/Config.h4
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp19
-rw-r--r--cpp/src/Ice/CommunicatorI.h5
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp8
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h4
-rw-r--r--cpp/src/Ice/ThreadPool.cpp24
-rw-r--r--cpp/src/Ice/ThreadPool.h12
-rw-r--r--cpp/src/slice2cpp/Gen.cpp7
-rw-r--r--slice/Ice/Communicator.ice7
-rw-r--r--slice/Ice/Connection.ice11
-rw-r--r--slice/Ice/ObjectAdapter.ice9
-rwxr-xr-xswift/config/xcode-slice2cpp.sh2
-rw-r--r--swift/src/Ice/AdminFacetFactory.swift23
-rw-r--r--swift/src/Ice/CommunicatorI.swift40
-rw-r--r--swift/src/Ice/ConnectionI.swift57
-rw-r--r--swift/src/Ice/ObjectAdapterI.swift37
-rw-r--r--swift/src/Ice/PropertiesAdminI.swift5
-rw-r--r--swift/src/IceObjc/Communicator.h3
-rw-r--r--swift/src/IceObjc/Communicator.mm10
-rw-r--r--swift/src/IceObjc/ObjectAdapter.h1
-rw-r--r--swift/src/IceObjc/ObjectAdapter.mm5
21 files changed, 150 insertions, 143 deletions
diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h
index 10fe77f48d0..fec3a424945 100644
--- a/cpp/include/Ice/Config.h
+++ b/cpp/include/Ice/Config.h
@@ -26,6 +26,10 @@
# endif
#endif
+#ifdef ICE_SWIFT
+# include <dispatch/dispatch.h>
+#endif
+
//
// Define the Ice and IceInternal namespace, so that we can use the following
// everywhere in our code:
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 36198c82d75..4355ad80977 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -18,6 +18,9 @@
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
#include <Ice/UUID.h>
+#ifdef ICE_SWIFT
+#include <Ice/ThreadPool.h>
+#endif
using namespace std;
using namespace Ice;
@@ -378,6 +381,22 @@ Ice::CommunicatorI::getValueFactoryManager() const ICE_NOEXCEPT
return _instance->initializationData().valueFactoryManager;
}
+#ifdef ICE_SWIFT
+
+dispatch_queue_t
+Ice::CommunicatorI::getClientDispatchQueue() const ICE_NOEXCEPT
+{
+ return _instance->clientThreadPool()->getDispatchQueue();
+}
+
+dispatch_queue_t
+Ice::CommunicatorI::getServerDispatchQueue() const ICE_NOEXCEPT
+{
+ return _instance->serverThreadPool()->getDispatchQueue();
+}
+
+#endif
+
namespace
{
diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h
index f28b49a2299..ae0f4e817c8 100644
--- a/cpp/src/Ice/CommunicatorI.h
+++ b/cpp/src/Ice/CommunicatorI.h
@@ -97,6 +97,11 @@ public:
virtual ValueFactoryManagerPtr getValueFactoryManager() const ICE_NOEXCEPT;
+#ifdef ICE_SWIFT
+ virtual dispatch_queue_t getClientDispatchQueue() const ICE_NOEXCEPT;
+ virtual dispatch_queue_t getServerDispatchQueue() const ICE_NOEXCEPT;
+#endif
+
#ifdef ICE_CPP11_MAPPING
virtual ::std::function<void()>
flushBatchRequestsAsync(CompressBatch,
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 937c74e54cc..102636af70d 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -735,6 +735,14 @@ Ice::ObjectAdapterI::setPublishedEndpoints(const EndpointSeq& newEndpoints)
}
}
+#ifdef ICE_SWIFT
+dispatch_queue_t
+Ice::ObjectAdapterI::getDispatchQueue() const ICE_NOEXCEPT
+{
+ return getThreadPool()->getDispatchQueue();
+}
+#endif
+
bool
Ice::ObjectAdapterI::isLocal(const ObjectPrxPtr& proxy) const
{
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index 9c024a90b64..00496d9133d 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -85,6 +85,10 @@ public:
virtual EndpointSeq getPublishedEndpoints() const ICE_NOEXCEPT;
virtual void setPublishedEndpoints(const EndpointSeq&);
+#ifdef ICE_SWIFT
+ virtual dispatch_queue_t getDispatchQueue() const ICE_NOEXCEPT;
+#endif
+
bool isLocal(const ObjectPrxPtr&) const;
void flushAsyncBatchRequests(const IceInternal::CommunicatorFlushBatchAsyncPtr&, CompressBatch);
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index b836137170a..2994f292d86 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -245,7 +245,11 @@ IceInternal::ThreadPoolWorkQueue::getNativeInfo()
IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& prefix, int timeout) :
_instance(instance),
+#ifdef ICE_SWIFT
+ _dispatchQueue(dispatch_queue_create(prefix.c_str(), DISPATCH_QUEUE_CONCURRENT)),
+#else
_dispatcher(_instance->initializationData().dispatcher),
+#endif
_destroyed(false),
_prefix(prefix),
_selector(instance),
@@ -417,6 +421,9 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
IceInternal::ThreadPool::~ThreadPool()
{
assert(_destroyed);
+#ifdef ICE_SWIFT
+ dispatch_release(_dispatchQueue);
+#endif
}
void
@@ -531,6 +538,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
@@ -566,6 +579,7 @@ IceInternal::ThreadPool::dispatchFromThisThread(const DispatchWorkItemPtr& workI
{
workItem->run();
}
+#endif
}
void
@@ -603,6 +617,16 @@ IceInternal::ThreadPool::prefix() const
return _prefix;
}
+#ifdef ICE_SWIFT
+
+dispatch_queue_t
+IceInternal::ThreadPool::getDispatchQueue() const
+{
+ return _dispatchQueue;
+}
+
+#endif
+
void
IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread)
{
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
index f9641296a14..daff7373f1a 100644
--- a/cpp/src/Ice/ThreadPool.h
+++ b/cpp/src/Ice/ThreadPool.h
@@ -110,6 +110,10 @@ public:
std::string prefix() const;
+#ifdef ICE_SWIFT
+ dispatch_queue_t getDispatchQueue() const;
+#endif
+
private:
void run(const EventHandlerThreadPtr&);
@@ -127,10 +131,14 @@ private:
std::string nextThreadId();
const InstancePtr _instance;
-#ifdef ICE_CPP11_MAPPING
+#ifdef ICE_SWIFT
+ const dispatch_queue_t _dispatchQueue;
+#else // Ice for Swift does not support a dispatcher
+# ifdef ICE_CPP11_MAPPING
std::function<void(std::function<void()>, const std::shared_ptr<Ice::Connection>&)> _dispatcher;
-#else
+# else
const Ice::DispatcherPtr _dispatcher;
+# endif
#endif
ThreadPoolWorkQueuePtr _workQueue;
bool _destroyed;
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 6315c900650..afb8f2976c7 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -5686,6 +5686,13 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin
}
}
+ if(BuiltinPtr::dynamicCast(cont) &&
+ BuiltinPtr::dynamicCast(cont)->kind() == Builtin::KindLocalObject &&
+ ss.find("type:") == 0)
+ {
+ continue;
+ }
+
dc->warning(InvalidMetaData, file, line, "ignoring invalid metadata `" + s + "'");
newMetaData.remove(s);
continue;
diff --git a/slice/Ice/Communicator.ice b/slice/Ice/Communicator.ice
index 60a09a8f373..cbf42e5d93f 100644
--- a/slice/Ice/Communicator.ice
+++ b/slice/Ice/Communicator.ice
@@ -612,6 +612,13 @@ local interface Communicator
**/
["swift:noexcept"] FacetMap findAllAdminFacets();
#endif
+
+#if defined(__SLICE2SWIFT__) || defined(ICE_SWIFT)
+ ["cpp:const", "cpp:noexcept", "swift:nonnull", "swift:noexcept",
+ "cpp:type:dispatch_queue_t", "swift:type:Dispatch.DispatchQueue"] LocalObject getClientDispatchQueue();
+ ["cpp:const", "cpp:noexcept", "swift:nonnull", "swift:noexcept",
+ "cpp:type:dispatch_queue_t", "swift:type:Dispatch.DispatchQueue"] LocalObject getServerDispatchQueue();
+#endif
}
#endif
diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice
index a30eaa0539b..af1a6a0058b 100644
--- a/slice/Ice/Connection.ice
+++ b/slice/Ice/Connection.ice
@@ -313,12 +313,7 @@ local interface Connection
* @param callback The close callback object.
*
**/
- #ifdef __SLICE2SWIFT__
- void setCloseCallback(["swift:nonnull", "swift:type:Dispatch.DispatchQueue"] LocalObject runOn,
- CloseCallback callback);
- #else
void setCloseCallback(CloseCallback callback);
- #endif
/**
*
@@ -329,13 +324,7 @@ local interface Connection
* @param callback The heartbeat callback object.
*
**/
- #ifdef __SLICE2SWIFT__
- ["swift:noexcept"]
- void setHeartbeatCallback(["swift:nonnull", "swift:type:Dispatch.DispatchQueue"] LocalObject runOn,
- HeartbeatCallback callback);
- #else
["swift:noexcept"] void setHeartbeatCallback(HeartbeatCallback callback);
- #endif
/**
*
diff --git a/slice/Ice/ObjectAdapter.ice b/slice/Ice/ObjectAdapter.ice
index b66200b5294..3d8fca1cd59 100644
--- a/slice/Ice/ObjectAdapter.ice
+++ b/slice/Ice/ObjectAdapter.ice
@@ -32,9 +32,6 @@
module Ice
{
-#ifdef __SLICE2SWIFT__
- local interface DispatchQueue;
-#endif
/**
*
* The object adapter provides an up-call interface from the Ice
@@ -696,9 +693,11 @@ local interface ObjectAdapter
**/
void setPublishedEndpoints(EndpointSeq newEndpoints);
-#ifdef __SLICE2SWIFT__
+#if defined(__SLICE2SWIFT__) || defined(ICE_SWIFT)
// Get the dispatch queue associated with this Object Adapter
- ["swift:noexcept", "swift:nonnull"] DispatchQueue getDispatchQueue();
+ ["cpp:const", "cpp:noexcept", "swift:nonnull", "swift:noexcept",
+ "cpp:type:dispatch_queue_t", "swift:type:Dispatch.DispatchQueue"]
+ LocalObject getDispatchQueue();
#endif
}
diff --git a/swift/config/xcode-slice2cpp.sh b/swift/config/xcode-slice2cpp.sh
index 1b45a022aa8..ba2f4936cab 100755
--- a/swift/config/xcode-slice2cpp.sh
+++ b/swift/config/xcode-slice2cpp.sh
@@ -12,6 +12,6 @@ fi
BASENAME=$(basename -- "$INPUT_FILE_PATH")
BASENAME="${BASENAME%.*}"
mkdir -p "$DERIVED_FILE_DIR/$1"
-$SLICE2CPP -I"$SRCROOT/../slice" --include-dir $1 --output-dir "$DERIVED_FILE_DIR/$1" "$INPUT_FILE_PATH"
+$SLICE2CPP -I"$SRCROOT/../slice" -D ICE_SWIFT --include-dir $1 --output-dir "$DERIVED_FILE_DIR/$1" "$INPUT_FILE_PATH"
mkdir -p "$SYMROOT/$PLATFORM_NAME/include/$1"
mv "$DERIVED_FILE_DIR/$1/$BASENAME.h" "$SYMROOT/$PLATFORM_NAME/include/$1/$BASENAME.h"
diff --git a/swift/src/Ice/AdminFacetFactory.swift b/swift/src/Ice/AdminFacetFactory.swift
index fbc8f80fab0..ca4d3c3dffa 100644
--- a/swift/src/Ice/AdminFacetFactory.swift
+++ b/swift/src/Ice/AdminFacetFactory.swift
@@ -19,8 +19,7 @@ class AdminFacetFacade: ICEBlobjectFacade {
response: @escaping ICEBlobjectResponse,
exception: @escaping ICEBlobjectException) {
let objectAdapter = adapter.getSwiftObject(ObjectAdapterI.self) {
- let queue = (communicator as! CommunicatorI).getDispatchQueue(adapter.getName(), forAdmin: true)
- let oa = ObjectAdapterI(handle: adapter, communicator: communicator, queue: queue)
+ let oa = ObjectAdapterI(handle: adapter, communicator: communicator)
// Register the admin OA's id with the servant manager. This is used to distinguish between
// ObjectNotExistException and FacetNotExistException when a servant is not found on
@@ -49,25 +48,7 @@ class AdminFacetFacade: ICEBlobjectFacade {
exception: exception,
current: current)
- let queue = objectAdapter.getDispatchQueue()
-
- //
- // Check if we are in a collocated dispatch (con == nil) on the OA's queue by
- // checking if this object adapter is in the current execution context's dispatch speceific data.
- // If so, we use the current thread, otherwise dispatch to the OA's queue.
- //
- if con == nil,
- let adapters = DispatchQueue.getSpecific(key: (communicator as! CommunicatorI).dispatchSpecificKey),
- adapters.contains(objectAdapter) {
- dispatchPrecondition(condition: .onQueue(queue))
- dispatch(incoming: incoming, current: current)
- return
- }
-
- dispatchPrecondition(condition: .notOnQueue(queue))
- queue.sync {
- dispatch(incoming: incoming, current: current)
- }
+ dispatch(incoming: incoming, current: current)
}
func dispatch(incoming: Incoming, current: Current) {
diff --git a/swift/src/Ice/CommunicatorI.swift b/swift/src/Ice/CommunicatorI.swift
index 959b6f90583..5d210a526f0 100644
--- a/swift/src/Ice/CommunicatorI.swift
+++ b/swift/src/Ice/CommunicatorI.swift
@@ -9,17 +9,11 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator {
private let valueFactoryManager: ValueFactoryManager = ValueFactoryManagerI()
let defaultsAndOverrides: DefaultsAndOverrides
let initData: InitializationData
- private let serverQueue = DispatchQueue(label: "com.zeroc.ice.server", attributes: .concurrent)
- let dispatchSpecificKey = DispatchSpecificKey<Set<ObjectAdapterI>>()
let classGraphDepthMax: Int32
- private var mutex: Mutex = Mutex()
- private var adminDispatchQueue: Dispatch.DispatchQueue
-
init(handle: ICECommunicator, initData: InitializationData) {
defaultsAndOverrides = DefaultsAndOverrides(handle: handle)
self.initData = initData
- adminDispatchQueue = serverQueue
let num = initData.properties!.getPropertyAsIntWithDefault(key: "Ice.ClassGraphDepthMax", value: 50)
if num < 1 || num > 0x7FFF_FFFF {
classGraphDepthMax = 0x7FFF_FFFF
@@ -94,21 +88,21 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator {
return try autoreleasepool {
let handle = try _handle.createObjectAdapter(name)
- return ObjectAdapterI(handle: handle, communicator: self, queue: getDispatchQueue(name))
+ return ObjectAdapterI(handle: handle, communicator: self)
}
}
func createObjectAdapterWithEndpoints(name: String, endpoints: String) throws -> ObjectAdapter {
return try autoreleasepool {
let handle = try _handle.createObjectAdapterWithEndpoints(name: name, endpoints: endpoints)
- return ObjectAdapterI(handle: handle, communicator: self, queue: getDispatchQueue(name))
+ return ObjectAdapterI(handle: handle, communicator: self)
}
}
func createObjectAdapterWithRouter(name: String, rtr: RouterPrx) throws -> ObjectAdapter {
return try autoreleasepool {
let handle = try _handle.createObjectAdapterWithRouter(name: name, router: rtr._impl._handle)
- return ObjectAdapterI(handle: handle, communicator: self, queue: getDispatchQueue(name))
+ return ObjectAdapterI(handle: handle, communicator: self)
}
}
@@ -185,10 +179,6 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator {
// ObjectNotExistException and FacetNotExistException when a servant is not found on
// a Swift Admin OA.
(adapter as! ObjectAdapterI).servantManager.setAdminId(adminId)
-
- mutex.sync {
- adminDispatchQueue = adapter.getDispatchQueue()
- }
}
return _ObjectPrxI(handle: handle, communicator: self)
@@ -252,28 +242,12 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator {
}
}
- func getAdminDispatchQueue() -> DispatchQueue {
- return mutex.sync {
- adminDispatchQueue
- }
+ func getClientDispatchQueue() -> Dispatch.DispatchQueue {
+ return _handle.getClientDispatchQueue()
}
- func getDispatchQueue(_ name: String, forAdmin: Bool = false) -> Dispatch.DispatchQueue {
- if !name.isEmpty {
- if initData.properties!.getPropertyAsInt(name + ".ThreadPool.Size") > 0 ||
- initData.properties!.getPropertyAsInt(name + ".ThreadPool.SizeMax") > 0 ||
- !initData.properties!.getProperty(name + ".ThreadPool.ThreadPriority").isEmpty {
- // This OA has its own thread pool
- let queue = Dispatch.DispatchQueue(label: "com.zeroc.ice.oa." + name, attributes: .concurrent)
- if forAdmin {
- mutex.sync {
- adminDispatchQueue = queue
- }
- }
- return queue
- }
- }
- return serverQueue
+ func getServerDispatchQueue() -> Dispatch.DispatchQueue {
+ return _handle.getServerDispatchQueue()
}
}
diff --git a/swift/src/Ice/ConnectionI.swift b/swift/src/Ice/ConnectionI.swift
index 470a7ac4b2b..32c141b2a2c 100644
--- a/swift/src/Ice/ConnectionI.swift
+++ b/swift/src/Ice/ConnectionI.swift
@@ -38,37 +38,6 @@ public extension Connection {
}
}
}
-
- func setCloseCallback(runOn queue: DispatchQueue = DispatchQueue.global(), callback: CloseCallback?) throws {
- let handle = (self as! ConnectionI)._handle
- return try autoreleasepool {
- guard let cb = callback else {
- try handle.setCloseCallback(nil)
- return
- }
-
- try handle.setCloseCallback { c in
- queue.async {
- precondition(c.getCachedSwiftObject(ConnectionI.self) === self)
- cb(self)
- }
- }
- }
- }
-
- func setHeartbeatCallback(runOn queue: DispatchQueue = DispatchQueue.global(), callback: HeartbeatCallback?) {
- let handle = (self as! ConnectionI)._handle
- guard let cb = callback else {
- handle.setHeartbeatCallback(nil)
- return
- }
- handle.setHeartbeatCallback { c in
- queue.async {
- precondition(c.getCachedSwiftObject(ConnectionI.self) === self)
- cb(self)
- }
- }
- }
}
class ConnectionI: LocalObject<ICEConnection>, Connection {
@@ -113,6 +82,32 @@ class ConnectionI: LocalObject<ICEConnection>, Connection {
}
}
+ func setCloseCallback(_ callback: CloseCallback?) throws {
+ return try autoreleasepool {
+ guard let cb = callback else {
+ try _handle.setCloseCallback(nil)
+ return
+ }
+
+ try _handle.setCloseCallback { c in
+ precondition(c.getCachedSwiftObject(ConnectionI.self) === self)
+ cb(self)
+ }
+ }
+ }
+
+ func setHeartbeatCallback(_ callback: HeartbeatCallback?) {
+ guard let cb = callback else {
+ _handle.setHeartbeatCallback(nil)
+ return
+ }
+
+ _handle.setHeartbeatCallback { c in
+ precondition(c.getCachedSwiftObject(ConnectionI.self) === self)
+ cb(self)
+ }
+ }
+
func heartbeat() throws {
return try autoreleasepool {
try _handle.heartbeat()
diff --git a/swift/src/Ice/ObjectAdapterI.swift b/swift/src/Ice/ObjectAdapterI.swift
index b63f9552ef0..e23e2f10482 100644
--- a/swift/src/Ice/ObjectAdapterI.swift
+++ b/swift/src/Ice/ObjectAdapterI.swift
@@ -7,24 +7,13 @@ import IceObjc
class ObjectAdapterI: LocalObject<ICEObjectAdapter>, ObjectAdapter, ICEBlobjectFacade, Hashable {
private let communicator: Communicator
let servantManager: ServantManager
- private let queue: DispatchQueue
- private let dispatchSpecificKey: DispatchSpecificKey<Set<ObjectAdapterI>>
- init(handle: ICEObjectAdapter, communicator: Communicator, queue: DispatchQueue) {
+ init(handle: ICEObjectAdapter, communicator: Communicator) {
self.communicator = communicator
servantManager = ServantManager(adapterName: handle.getName(), communicator: communicator)
- self.queue = queue
- dispatchSpecificKey = (communicator as! CommunicatorI).dispatchSpecificKey
super.init(handle: handle)
handle.registerDefaultServant(self)
-
- // Add self to the queue's dispatch specific data
- queue.async(flags: .barrier) {
- var adapters = queue.getSpecific(key: self.dispatchSpecificKey) ?? Set<ObjectAdapterI>()
- adapters.insert(self)
- queue.setSpecific(key: self.dispatchSpecificKey, value: adapters)
- }
}
func hash(into hasher: inout Hasher) {
@@ -194,7 +183,7 @@ class ObjectAdapterI: LocalObject<ICEObjectAdapter>, ObjectAdapter, ICEBlobjectF
}
func getDispatchQueue() -> DispatchQueue {
- return queue
+ return _handle.getDispatchQueue()
}
func facadeInvoke(_ adapter: ICEObjectAdapter,
@@ -233,30 +222,10 @@ class ObjectAdapterI: LocalObject<ICEObjectAdapter>, ObjectAdapter, ICEBlobjectF
exception: exception,
current: current)
- //
- // Check if we are in a collocated dispatch (con == nil) on the OA's queue by
- // checking if this object adapter is in the current execution context's dispatch speceific data.
- // If so, we use the current thread, otherwise dispatch to the OA's queue.
- //
- if con == nil, let adapters = DispatchQueue.getSpecific(key: dispatchSpecificKey), adapters.contains(self) {
- dispatchPrecondition(condition: .onQueue(queue))
- incoming.invoke(servantManager)
- return
- }
- dispatchPrecondition(condition: .notOnQueue(queue))
- queue.sync {
- incoming.invoke(servantManager)
- }
+ incoming.invoke(servantManager)
}
func facadeRemoved() {
servantManager.destroy()
- queue.async(flags: .barrier) {
- guard var adapters = self.queue.getSpecific(key: self.dispatchSpecificKey) else {
- preconditionFailure("ObjectAdapter missing from dispatch specific data")
- }
- adapters.remove(self)
- self.queue.setSpecific(key: self.dispatchSpecificKey, value: adapters)
- }
}
}
diff --git a/swift/src/Ice/PropertiesAdminI.swift b/swift/src/Ice/PropertiesAdminI.swift
index 0b9ceca5e1e..3b9bf7a89d5 100644
--- a/swift/src/Ice/PropertiesAdminI.swift
+++ b/swift/src/Ice/PropertiesAdminI.swift
@@ -32,10 +32,7 @@ class PropertiesAdminI: LocalObject<ICEPropertiesAdmin>, PropertiesAdmin, Native
func addUpdateCallback(_ cb: @escaping PropertiesAdminUpdateCallback) -> PropertiesAdminRemoveCallback {
return _handle.addUpdateCallback { (props: PropertyDict) in
- // Run callback closure in the Admin OAs dispatch queue
- (self.communicator as! CommunicatorI).getAdminDispatchQueue().sync {
- cb(props)
- }
+ cb(props)
}
}
}
diff --git a/swift/src/IceObjc/Communicator.h b/swift/src/IceObjc/Communicator.h
index 9bdc7e043b6..d36e76fa5d7 100644
--- a/swift/src/IceObjc/Communicator.h
+++ b/swift/src/IceObjc/Communicator.h
@@ -44,8 +44,9 @@ NS_ASSUME_NONNULL_BEGIN
-(nullable id<ICEBlobjectFacade>) removeAdminFacet:(NSString*)facet error:(NSError**)error;
-(nullable id) findAdminFacet:(NSString*)facet error:(NSError**)error;
-(nullable NSDictionary<NSString*, id<ICEBlobjectFacade>>*) findAllAdminFacets:(NSError**)error;
-
-(ICEProperties*) getProperties;
+-(dispatch_queue_t) getClientDispatchQueue;
+-(dispatch_queue_t) getServerDispatchQueue;
// DefaultsAndOverrides
-(void) getDefaultEncoding:(nonnull uint8_t*)major minor:(nonnull uint8_t*)minor
diff --git a/swift/src/IceObjc/Communicator.mm b/swift/src/IceObjc/Communicator.mm
index b721ee86fe9..ad76fe04413 100644
--- a/swift/src/IceObjc/Communicator.mm
+++ b/swift/src/IceObjc/Communicator.mm
@@ -350,6 +350,16 @@
return [ICEProperties getHandle:props];
}
+-(dispatch_queue_t) getClientDispatchQueue
+{
+ return self.communicator->getClientDispatchQueue();
+}
+
+-(dispatch_queue_t) getServerDispatchQueue
+{
+ return self.communicator->getServerDispatchQueue();
+}
+
-(void) getDefaultEncoding:(nonnull uint8_t*)major minor:(nonnull uint8_t*)minor
{
auto defaultEncoding = IceInternal::getInstance(self.communicator)->defaultsAndOverrides()->defaultEncoding;
diff --git a/swift/src/IceObjc/ObjectAdapter.h b/swift/src/IceObjc/ObjectAdapter.h
index 9fb6e4df80a..2efb237e2fa 100644
--- a/swift/src/IceObjc/ObjectAdapter.h
+++ b/swift/src/IceObjc/ObjectAdapter.h
@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
-(BOOL) refreshPublishedEndpoints:(NSError* _Nullable * _Nullable)error;
-(NSArray<ICEEndpoint*>*) getPublishedEndpoints;
-(BOOL) setPublishedEndpoints:(NSArray<ICEEndpoint*>*)newEndpoints error:(NSError* _Nullable * _Nullable)error;
+-(dispatch_queue_t) getDispatchQueue;
-(void) registerDefaultServant:(id<ICEBlobjectFacade>)facade NS_SWIFT_NAME(registerDefaultServant(_:));
@end
diff --git a/swift/src/IceObjc/ObjectAdapter.mm b/swift/src/IceObjc/ObjectAdapter.mm
index cdd1310b4bc..7268996c0b5 100644
--- a/swift/src/IceObjc/ObjectAdapter.mm
+++ b/swift/src/IceObjc/ObjectAdapter.mm
@@ -204,6 +204,11 @@
}
}
+-(dispatch_queue_t) getDispatchQueue
+{
+ return self.objectAdapter->getDispatchQueue();
+}
+
-(void) registerDefaultServant:(id<ICEBlobjectFacade>)facade
{
auto servant = std::make_shared<BlobjectFacade>(facade);