Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove AsyncResult AMI mapping #1737

Merged
merged 8 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 1 addition & 239 deletions cpp/src/slice2cs/Gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,23 +718,8 @@ Slice::CsVisitor::writeMarshaling(const ClassDefPtr& p)
string scoped = p->scoped();
string ns = getNamespace(p);
ClassList allBases = p->allBases();
StringList ids;
ClassDefPtr base = p->base();

transform(allBases.begin(), allBases.end(), back_inserter(ids),
[](const ContainedPtr& it)
{
return it->scoped();
});
StringList other;
other.push_back(p->scoped());
other.push_back("::Ice::Value");
other.sort();
ids.merge(other);
ids.unique();

assert(find(ids.begin(), ids.end(), scoped) != ids.end());

//
// Marshaling support
//
Expand Down Expand Up @@ -3613,71 +3598,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
<< ("global::System.Threading.CancellationToken " + cancel + " = new global::System.Threading.CancellationToken()")
<< epar << ";";
}

{
//
// Write the async versions of the operation (using IAsyncResult API)
//
string delType = "Callback_" + interface->name() + "_" + p->name();

string context = getEscapedParamName(p, "context");
string callback = getEscapedParamName(p, "callback");
string cookie = getEscapedParamName(p, "cookie");
string asyncResult = getEscapedParamName(p, "asyncResult");

_out << sp;
writeDocCommentAMI(p, InParam, deprecateReason,
"<param name=\"" + context + "\">The Context map to send with the invocation.</param>");
if(!deprecateReason.empty())
{
_out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]";
}
_out << nl << getUnqualified("Ice.AsyncResult", ns) << "<" << delType << "> begin_" << p->name() << spar
<< inParams
<< (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " +
getUnqualified("Ice.OptionalContext", ns) + "()") << epar << ';';

//
// Type-unsafe begin_ methods.
//
_out << sp;
writeDocCommentAMI(p, InParam, deprecateReason,
"<param name=\"" + callback + "\">Asynchronous callback invoked when the operation completes.</param>",
"<param name=\"" + cookie + "\">Application data to store in the asynchronous result object.</param>");
if(!deprecateReason.empty())
{
_out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]";
}
_out << nl << getUnqualified("Ice.AsyncResult", ns) << " begin_" << p->name() << spar << inParams
<< getUnqualified("Ice.AsyncCallback", ns) + " " + callback << "object " + cookie << epar << ';';

_out << sp;
writeDocCommentAMI(p, InParam, deprecateReason,
"<param name=\"" + context + "\">The Context map to send with the invocation.</param>",
"<param name=\"" + callback + "\">Asynchronous callback invoked when the operation completes.</param>",
"<param name=\"" + cookie + "\">Application data to store in the asynchronous result object.</param>");
if(!deprecateReason.empty())
{
_out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]";
}
_out << nl << getUnqualified("Ice.AsyncResult", ns) << " begin_" << p->name() << spar << inParams
<< getUnqualified("Ice.OptionalContext", ns) + " " + context
<< getUnqualified("Ice.AsyncCallback", ns) + " " + callback
<< "object " + cookie << epar << ';';

//
// end_ method.
//
_out << sp;
writeDocCommentAMI(p, OutParam, deprecateReason,
"<param name=\"" + asyncResult + "\">The asynchronous result object for the invocation.</param>");
if(!deprecateReason.empty())
{
_out << nl << "[global::System.Obsolete(\"" << deprecateReason << "\")]";
}
_out << nl << retS << " end_" << p->name() << spar << getOutParams(p, ns, false, true)
<< getUnqualified("Ice.AsyncResult", ns) + " " + asyncResult << epar << ';';
}
}

Slice::Gen::AsyncDelegateVisitor::AsyncDelegateVisitor(IceUtilInternal::Output& out)
Expand Down Expand Up @@ -3734,6 +3654,7 @@ Slice::Gen::AsyncDelegateVisitor::visitOperation(const OperationPtr& p)
}
_out << paramDeclAMI << epar << ';';
}

Slice::Gen::OpsVisitor::OpsVisitor(IceUtilInternal::Output& out)
: CsVisitor(out)
{
Expand Down Expand Up @@ -4212,165 +4133,6 @@ Slice::Gen::HelperVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p)

_out << sp << nl << "#endregion"; // Asynchronous Task operations

//
// IAsyncResult AMI mapping.
//
_out << sp << nl << "#region Asynchronous operations";
for(OperationList::const_iterator r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;

InterfaceDefPtr interface = op->interface();
vector<string> paramsAMI = getInParams(op, ns);
vector<string> argsAMI = getInArgs(op);
string opName = op->name();
ParamDeclList inParams = op->inParameters();
ParamDeclList outParams = op->outParameters();

TypePtr ret = op->returnType();
string retS = typeToString(ret, ns, op->returnIsOptional());

string returnTypeS = resultType(op, ns);

//
// Write the begin_ methods.
//
string clScope = getNamespace(interface);
string delType = getUnqualified(clScope + ".Callback_" + interface->name() + "_" + op->name(), ns);

string context = getEscapedParamName(op, "context");
string callback = getEscapedParamName(op, "callback");
string cookie = getEscapedParamName(op, "cookie");

_out << sp;
_out << nl << "public " << getUnqualified("Ice.AsyncResult", ns) << "<" << delType << "> begin_" << opName
<< spar << paramsAMI << (getUnqualified("Ice.OptionalContext", ns) + " " + context + " = new " +
getUnqualified("Ice.OptionalContext", ns) + "()") << epar;
_out << sb;
_out << nl << "return begin_" << opName << spar << argsAMI << context << "null" << "null" << "false"
<< epar << ';';
_out << eb;

_out << sp;
_out << nl << "public " << getUnqualified("Ice.AsyncResult", ns) << " begin_" << opName << spar << paramsAMI
<< getUnqualified("Ice.AsyncCallback", ns) + " " + callback << "object " + cookie << epar;
_out << sb;
_out << nl << "return begin_" << opName << spar << argsAMI
<< "new " + getUnqualified("Ice.OptionalContext", ns) + "()" << callback << cookie << "false" << epar << ';';
_out << eb;

_out << sp;
_out << nl << "public " << getUnqualified("Ice.AsyncResult", ns) + " begin_" << opName << spar << paramsAMI
<< getUnqualified("Ice.OptionalContext", ns) + " " + context
<< getUnqualified("Ice.AsyncCallback", ns) + " " + callback
<< "object " + cookie << epar;
_out << sb;
_out << nl << "return begin_" << opName << spar << argsAMI << context << callback
<< cookie << "false" << epar << ';';
_out << eb;

//
// Write the end_ method.
//
string flatName = "_" + opName + "_name";
string asyncResult = getEscapedParamName(op, "asyncResult");

_out << sp << nl << "public " << retS << " end_" << opName << spar << getOutParams(op, ns, false, true)
<< getUnqualified("Ice.AsyncResult", ns) + " " + asyncResult << epar;
_out << sb;

_out << nl << "var resultI_ = global::IceInternal.AsyncResultI.check(" + asyncResult + ", this, " << flatName << ");";

if(returnTypeS.empty())
{
_out << nl << "((global::IceInternal.OutgoingAsyncT<object>)resultI_.OutgoingAsync).getResult(resultI_.wait());";
}
else
{
_out << nl << "var outgoing_ = (global::IceInternal.OutgoingAsyncT<" << returnTypeS << ">)resultI_.OutgoingAsync;";
if(outParams.empty())
{
_out << nl << "return outgoing_.getResult(resultI_.wait());";
}
else if(!ret && outParams.size() == 1)
{
_out << nl << fixId(outParams.front()->name()) << " = outgoing_.getResult(resultI_.wait());";
}
else
{
_out << nl << "var result_ = outgoing_.getResult(resultI_.wait());";
for(ParamDeclList::const_iterator i = outParams.begin(); i != outParams.end(); ++i)
{
_out << nl << fixId((*i)->name()) << " = result_." << fixId((*i)->name()) << ";";
}

if(ret)
{
_out << nl << "return result_." << resultStructReturnValueName(outParams) << ";";
}
}
}
_out << eb;

//
// Write the common begin_ implementation.
//
_out << sp;
_out << nl << "private " << getUnqualified("Ice.AsyncResult", ns) << "<" << delType << "> begin_" << opName << spar
<< getInParams(op, ns, true)
<< "global::System.Collections.Generic.Dictionary<string, string> context"
<< getUnqualified("Ice.AsyncCallback", ns) + " completedCallback" << "object cookie" << "bool synchronous"
<< epar;
_out << sb;

if(op->returnsData())
{
_out << nl << "iceCheckAsyncTwowayOnly(" << flatName << ");";
}
_out << nl << "var completed = new global::IceInternal.OperationAsyncResultCompletionCallback<" << delType;
_out << ", " << (returnTypeS.empty() ? "object" : returnTypeS);
_out << ">(";

//
// Write the completed callback
//
_out.inc();
_out << nl << "(" << delType << " cb, " << (returnTypeS.empty() ? "object" : returnTypeS) << " ret) =>";
_out << sb;
_out << nl << "if(cb != null)";
_out << sb;
_out << nl << "cb.Invoke" << spar;
if(ret && outParams.empty())
{
_out << "ret";
}
else if(ret || outParams.size() > 1)
{
if(ret)
{
_out << "ret." + resultStructReturnValueName(outParams);
}
for(ParamDeclList::const_iterator pli = outParams.begin(); pli != outParams.end(); ++pli)
{
_out << "ret." + fixId((*pli)->name());
}
}
else if(!outParams.empty())
{
_out << "ret";
}
_out << epar << ';';
_out << eb;
_out << eb << ",";
_out << nl << "this, " << flatName << ", cookie, completedCallback);";

_out.dec();
_out << nl << "_iceI_" << op->name() << spar << getInArgs(op, true) << "context" << "synchronous" << "completed"
<< epar << ";";
_out << nl << "return completed;";
_out << eb;
}
_out << sp << nl << "#endregion"; // Asynchronous operations
_out << sp << nl << "#region Checked and unchecked cast operations";

_out << sp << nl << "public static " << name << "Prx checkedCast(" << getUnqualified("Ice.ObjectPrx", ns) << " b)";
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Ice/BatchRequestQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void

if(_maxSize > 0 && _batchStream.size() >= _maxSize)
{
proxy.begin_ice_flushBatchRequests(); // Auto flush
_ = proxy.ice_flushBatchRequestsAsync(); // Auto flush
}

Debug.Assert(_batchMarker < _batchStream.size());
Expand Down
6 changes: 0 additions & 6 deletions csharp/src/Ice/Communicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,6 @@ public partial interface Communicator : global::System.IDisposable
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
global::System.Threading.Tasks.Task flushBatchRequestsAsync(CompressBatch compress, global::System.IProgress<bool> progress = null, global::System.Threading.CancellationToken cancel = new global::System.Threading.CancellationToken());

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
AsyncResult begin_flushBatchRequests(CompressBatch compress, AsyncCallback callback = null, object cookie = null);

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
void end_flushBatchRequests(AsyncResult asyncResult);

/// <summary>
/// Add the Admin object with all its facets to the provided object adapter.
/// If Ice.Admin.ServerId is
Expand Down
29 changes: 0 additions & 29 deletions csharp/src/Ice/CommunicatorI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ public Task flushBatchRequestsAsync(Ice.CompressBatch compressBatch,
return completed.Task;
}

public AsyncResult begin_flushBatchRequests(Ice.CompressBatch compressBatch)
{
return begin_flushBatchRequests(compressBatch, null, null);
}

private const string _flushBatchRequests_name = "flushBatchRequests";

private class CommunicatorFlushBatchCompletionCallback : AsyncResultCompletionCallback
Expand Down Expand Up @@ -226,30 +221,6 @@ protected override AsyncCallback getCompletedCallback()
}
};

public AsyncResult begin_flushBatchRequests(Ice.CompressBatch compressBatch, AsyncCallback cb, object cookie)
{
var result = new CommunicatorFlushBatchCompletionCallback(this,
_instance,
_flushBatchRequests_name,
cookie,
cb);
var outgoing = new CommunicatorFlushBatchAsync(_instance, result);
outgoing.invoke(_flushBatchRequests_name, compressBatch, false);
return result;
}

public void end_flushBatchRequests(AsyncResult result)
{
if(result != null && result.getCommunicator() != this)
{
const string msg = "Communicator for call to end_" + _flushBatchRequests_name +
" does not match communicator that was used to call corresponding begin_" +
_flushBatchRequests_name + " method";
throw new ArgumentException(msg);
}
AsyncResultI.check(result, _flushBatchRequests_name).wait();
}

public ObjectPrx createAdmin(ObjectAdapter adminAdapter, Identity adminIdentity)
{
return _instance.createAdmin(adminAdapter, adminIdentity);
Expand Down
12 changes: 0 additions & 12 deletions csharp/src/Ice/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,6 @@ public partial interface Connection
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
global::System.Threading.Tasks.Task flushBatchRequestsAsync(CompressBatch compress, global::System.IProgress<bool> progress = null, global::System.Threading.CancellationToken cancel = new global::System.Threading.CancellationToken());

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
AsyncResult begin_flushBatchRequests(CompressBatch compress, AsyncCallback callback = null, object cookie = null);

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
void end_flushBatchRequests(AsyncResult asyncResult);

/// <summary>
/// Set a close callback on the connection.
/// The callback is called by the connection when it's closed. The callback
Expand Down Expand Up @@ -411,12 +405,6 @@ public partial interface Connection
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
global::System.Threading.Tasks.Task heartbeatAsync(global::System.IProgress<bool> progress = null, global::System.Threading.CancellationToken cancel = new global::System.Threading.CancellationToken());

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
AsyncResult begin_heartbeat(AsyncCallback callback = null, object cookie = null);

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")]
void end_heartbeat(AsyncResult asyncResult);

/// <summary>
/// Set the active connection management parameters.
/// </summary>
Expand Down
Loading
Loading