Skip to content

Commit

Permalink
Remove sent callback in Swift (#2601)
Browse files Browse the repository at this point in the history
  • Loading branch information
externl authored Aug 1, 2024
1 parent fe1f0d2 commit 82e5cd9
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 308 deletions.
21 changes: 1 addition & 20 deletions cpp/src/slice2swift/SwiftUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,18 +712,6 @@ SwiftGenerator::writeOpDocSummary(IceInternal::Output& out, const OperationPtr&

if (async)
{
if (!dispatch)
{
out << nl << "///";
out << nl << "/// - parameter sentOn: `Dispatch.DispatchQueue?` - Optional dispatch queue used to";
out << nl << "/// dispatch the sent callback.";
out << nl << "///";
out << nl << "/// - parameter sentFlags: `Dispatch.DispatchWorkItemFlags?` - Optional dispatch flags used";
out << nl << "/// to dispatch the sent callback";
out << nl << "///";
out << nl << "/// - parameter sent: `((Swift.Bool) -> Swift.Void)` - Optional sent callback.";
}

out << nl << "///";
out << nl << "/// - returns: `" << operationReturnType(p, typeCtx) << "` - The result of the operation";
}
Expand Down Expand Up @@ -2495,10 +2483,6 @@ SwiftGenerator::writeProxyAsyncOperation(::IceInternal::Output& out, const Opera
}
}
out << "context: " + getUnqualified("Ice.Context", swiftModule) + "? = nil";
out << "sentOn: Dispatch.DispatchQueue? = nil";
out << "sentFlags: Dispatch.DispatchWorkItemFlags? = nil";
out << "sent: ((Swift.Bool) -> Swift.Void)? = nil";

out << epar;
out << " async throws -> ";
if (allOutParams.empty())
Expand Down Expand Up @@ -2549,10 +2533,7 @@ SwiftGenerator::writeProxyAsyncOperation(::IceInternal::Output& out, const Opera
out << ",";
}

out << nl << "context: context,";
out << nl << "sentOn: sentOn,";
out << nl << "sentFlags: sentFlags,";
out << nl << "sent: sent)";
out << nl << "context: context)";
out.restoreIndent();

out << eb;
Expand Down
13 changes: 1 addition & 12 deletions swift/src/Ice/Communicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,8 @@ public protocol Communicator: AnyObject {
///
/// - parameter _: `CompressBatch` Specifies whether or not the queued batch requests should be compressed before
/// being sent over the wire.
///
/// - parameter sentOn: `Dispatch.DispatchQueue?` - Optional dispatch queue used to
/// dispatch the sent callback.
///
/// - parameter sentFlags: `Dispatch.DispatchWorkItemFlags?` - Optional dispatch flags used
/// to dispatch the sent callback
///
/// - parameter sent: `((Bool) -> Void)` - Optional sent callback.
func flushBatchRequestsAsync(
_ compress: CompressBatch,
sentOn: Dispatch.DispatchQueue?,
sentFlags: Dispatch.DispatchWorkItemFlags?,
sent: ((Bool) -> Void)?
_ compress: CompressBatch
) async throws

/// Add the Admin object with all its facets to the provided object adapter. If Ice.Admin.ServerId is
Expand Down
14 changes: 4 additions & 10 deletions swift/src/Ice/CommunicatorI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,17 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator {

extension Communicator {
public func flushBatchRequestsAsync(
_ compress: CompressBatch,
sentOn: DispatchQueue? = nil,
sentFlags: DispatchWorkItemFlags? = nil,
sent: ((Bool) -> Void)? = nil
_ compress: CompressBatch
) async throws {
let impl = self as! CommunicatorI
let sentCB = createSentCallback(sentOn: sentOn, sentFlags: sentFlags, sent: sent)
return try await withCheckedThrowingContinuation { continuation in
impl.handle.flushBatchRequestsAsync(
compress.rawValue,
exception: { continuation.resume(throwing: $0) },
sent: {
sent: { _ in
continuation.resume(returning: ())
if let sentCB = sentCB {
sentCB($0)
}
})
}
)
}
}

Expand Down
13 changes: 1 addition & 12 deletions swift/src/Ice/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,8 @@ public protocol Connection: AnyObject, CustomStringConvertible {
///
/// - parameter _: `CompressBatch` Specifies whether or not the queued batch requests should be compressed before
/// being sent over the wire.
///
/// - parameter sentOn: `Dispatch.DispatchQueue?` - Optional dispatch queue used to
/// dispatch the sent callback.
///
/// - parameter sentFlags: `Dispatch.DispatchWorkItemFlags?` - Optional dispatch flags used
/// to dispatch the sent callback
///
/// - parameter sent: `((Bool) -> Void)` - Optional sent callback.
func flushBatchRequestsAsync(
_ compress: CompressBatch,
sentOn: Dispatch.DispatchQueue?,
sentFlags: Dispatch.DispatchWorkItemFlags?,
sent: ((Bool) -> Void)?
_ compress: CompressBatch
) async throws

/// Set a close callback on the connection. The callback is called by the connection when it's closed. The callback
Expand Down
11 changes: 2 additions & 9 deletions swift/src/Ice/ConnectionI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,15 @@ import IceImpl

extension Connection {
public func flushBatchRequestsAsync(
_ compress: CompressBatch,
sentOn: DispatchQueue? = nil,
sentFlags: DispatchWorkItemFlags? = nil,
sent: ((Bool) -> Void)? = nil
_ compress: CompressBatch
) async throws {
let impl = self as! ConnectionI
let sentCB = createSentCallback(sentOn: sentOn, sentFlags: sentFlags, sent: sent)
return try await withCheckedThrowingContinuation { continuation in
impl.handle.flushBatchRequestsAsync(
compress.rawValue,
exception: { error in continuation.resume(throwing: error) },
sent: {
sent: { _ in
continuation.resume(returning: ())
if let sentCB = sentCB {
sentCB($0)
}
})
}
}
Expand Down
Loading

0 comments on commit 82e5cd9

Please sign in to comment.