diff options
author | Jose <jose@zeroc.com> | 2016-07-22 17:57:42 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-07-22 17:57:42 +0200 |
commit | b55c347b5178f62db2a175b55900217217a46dbc (patch) | |
tree | 914e89427afe92828aac9d01c0a2d7b4046e751a /csharp/src | |
parent | Merge remote-tracking branch 'origin/3.6' (diff) | |
download | ice-b55c347b5178f62db2a175b55900217217a46dbc.tar.bz2 ice-b55c347b5178f62db2a175b55900217217a46dbc.tar.xz ice-b55c347b5178f62db2a175b55900217217a46dbc.zip |
CSharp AMD mapping update
Diffstat (limited to 'csharp/src')
25 files changed, 211 insertions, 306 deletions
diff --git a/csharp/src/Glacier2/msbuild/glacier2.csproj b/csharp/src/Glacier2/msbuild/glacier2.csproj index bb24bc4a06b..87a7488f40f 100644 --- a/csharp/src/Glacier2/msbuild/glacier2.csproj +++ b/csharp/src/Glacier2/msbuild/glacier2.csproj @@ -81,7 +81,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/Ice/AMDCallback.cs b/csharp/src/Ice/AMDCallback.cs deleted file mode 100644 index 380a83d83c4..00000000000 --- a/csharp/src/Ice/AMDCallback.cs +++ /dev/null @@ -1,26 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -namespace Ice -{ - /// <summary> - /// AMDCallback is the interface from which all AMD callbacks are derived. - /// </summary> - public interface AMDCallback - { - /// <summary> - /// Indicates to the Ice run time that an operation completed - /// with a run-time exception. - /// </summary> - /// <param name="ex">The encoded Ice run-time exception. Note that, if ex - /// is a user exception, the caller receives UnknownUserException. - /// Use ice_response to raise user exceptions.</param> - void ice_exception(System.Exception ex); - } -} diff --git a/csharp/src/Ice/IncomingAsync.cs b/csharp/src/Ice/IncomingAsync.cs index 3008e5b72f3..103c5d6913d 100644 --- a/csharp/src/Ice/IncomingAsync.cs +++ b/csharp/src/Ice/IncomingAsync.cs @@ -7,12 +7,13 @@ // // ********************************************************************** +using System; +using System.Diagnostics; +using System.Threading.Tasks; + namespace IceInternal { - - using System.Diagnostics; - - public class IncomingAsync : IncomingBase, Ice.AMDCallback + public class IncomingAsync : IncomingBase { public IncomingAsync(Incoming inc) : base(inc) @@ -25,14 +26,13 @@ namespace IceInternal } } - virtual public void ice_exception(System.Exception ex) + virtual public void ice_exception(Exception ex) { // // Only call exception__ if this incoming is not retriable or if // all the interceptors return true and no response has been sent // yet. // - if(_retriable) { try @@ -48,7 +48,7 @@ namespace IceInternal } } } - catch(System.Exception) + catch(Exception) { return; } @@ -98,7 +98,7 @@ namespace IceInternal inc.adopt(this); } - protected void response__() + public void response__() { try { @@ -135,7 +135,7 @@ namespace IceInternal } } - protected internal void exception__(System.Exception exc) + public void exception__(Exception exc) { try { @@ -157,7 +157,7 @@ namespace IceInternal return os_; } - protected bool validateResponse__(bool ok) + public bool validateResponse__(bool ok) { // // Only returns true if this incoming is not retriable or if all @@ -181,7 +181,7 @@ namespace IceInternal } } } - catch(System.Exception) + catch(Exception) { return false; } @@ -202,46 +202,3 @@ namespace IceInternal private bool _active = false; // only meaningful when _retriable == true } } - -namespace Ice -{ - - /// <summary> - /// Callback interface for Blobject AMD servants. - /// </summary> - public interface AMD_Object_ice_invoke : Ice.AMDCallback - { - /// <summary> - /// Indicates to the Ice run time that an operation - /// completed. - /// </summary> - /// <param name="ok">True indicates that the operation - /// completed successfully; false indicates that the - /// operation raised a user exception.</param> - /// <param name="outEncaps">The encoded out-parameters for the operation or, - /// if ok is false, the encoded user exception.</param> - void ice_response(bool ok, byte[] outEncaps); - } - - sealed class _AMD_Object_ice_invoke : IceInternal.IncomingAsync, AMD_Object_ice_invoke - { - public _AMD_Object_ice_invoke(IceInternal.Incoming inc) - : base(inc) - { - } - - public void ice_response(bool ok, byte[] outEncaps) - { - try - { - writeParamEncaps__(outEncaps, ok); - } - catch(Ice.LocalException ex) - { - exception__(ex); - return; - } - response__(); - } - } -} diff --git a/csharp/src/Ice/LoggerAdminI.cs b/csharp/src/Ice/LoggerAdminI.cs index 0b8b872ee09..1c421c7c8f9 100644 --- a/csharp/src/Ice/LoggerAdminI.cs +++ b/csharp/src/Ice/LoggerAdminI.cs @@ -81,7 +81,24 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ try { - remoteLogger.begin_init(_logger.getPrefix(), initLogMessages.ToArray(), initCompleted, null); + remoteLogger.initAsync(_logger.getPrefix(), initLogMessages.ToArray()).ContinueWith( + (t) => + { + try + { + t.Wait(); + if(_traceLevel > 1) + { + _logger.trace(_traceCategory,"init on `" + remoteLogger.ToString() + + "' completed successfully"); + } + } + catch(System.AggregateException ae) + { + Debug.Assert(ae.InnerException is Ice.LocalException); + deadRemoteLogger(remoteLogger, _logger, (Ice.LocalException)ae.InnerException, "init"); + } + }); } catch(Ice.LocalException ex) { @@ -305,26 +322,6 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ return _remoteLoggerMap.Remove(remoteLogger.ice_getIdentity()); } } - - private void initCompleted(Ice.AsyncResult r) - { - Ice.RemoteLoggerPrx remoteLogger = Ice.RemoteLoggerPrxHelper.uncheckedCast(r.getProxy()); - - try - { - remoteLogger.end_init(r); - - if(_traceLevel > 1) - { - _logger.trace(_traceCategory, r.getOperation() + " on `" + remoteLogger.ToString() - + "' completed successfully"); - } - } - catch(Ice.LocalException ex) - { - deadRemoteLogger(remoteLogger, _logger, ex, r.getOperation()); - } - } private static void filterLogMessages(LinkedList<Ice.LogMessage> logMessages, HashSet<Ice.LogMessageType> messageTypes, diff --git a/csharp/src/Ice/LoggerAdminLoggerI.cs b/csharp/src/Ice/LoggerAdminLoggerI.cs index b80f75e25fc..221358a7243 100644 --- a/csharp/src/Ice/LoggerAdminLoggerI.cs +++ b/csharp/src/Ice/LoggerAdminLoggerI.cs @@ -171,7 +171,31 @@ sealed class LoggerAdminLoggerI : LoggerAdminLogger // // p is a proxy associated with the _sendLogCommunicator // - p.begin_log(job.logMessage, logCompleted, null); + p.logAsync(job.logMessage).ContinueWith( + (t) => + { + try + { + t.Wait(); + if(_loggerAdmin.getTraceLevel() > 1) + { + _localLogger.trace(_traceCategory, "log on `" + p.ToString() + + "' completed successfully"); + } + } + catch(AggregateException ae) + { + if(ae.InnerException is Ice.CommunicatorDestroyedException) + { + // expected if there are outstanding calls during communicator destruction + } + if(ae.InnerException is Ice.LocalException) + { + _loggerAdmin.deadRemoteLogger(p, _localLogger, + (Ice.LocalException)ae.InnerException, "log"); + } + } + }); } catch(Ice.LocalException ex) { diff --git a/csharp/src/Ice/Object.cs b/csharp/src/Ice/Object.cs index 53ab5237c72..8ea9617b641 100644 --- a/csharp/src/Ice/Object.cs +++ b/csharp/src/Ice/Object.cs @@ -9,6 +9,7 @@ using System; using System.Collections; +using System.Threading.Tasks; using System.Diagnostics; namespace Ice @@ -62,37 +63,16 @@ namespace Ice /// </summary> /// /// <param name="s">The type ID of the Slice interface to test against.</param> - /// <returns>True if this object has the interface - /// specified by s or derives from the interface specified by s.</returns> - bool ice_isA(string s); - - /// <summary> - /// Tests whether this object supports a specific Slice interface. - /// </summary> - /// - /// <param name="s">The type ID of the Slice interface to test against.</param> /// <param name="current">The Current object for the invocation.</param> /// <returns>True if this object has the interface /// specified by s or derives from the interface specified by s.</returns> - bool ice_isA(string s, Current current); - - /// <summary> - /// Tests whether this object can be reached. - /// </summary> - void ice_ping(); + bool ice_isA(string s, Current current = null); /// <summary> /// Tests whether this object can be reached. /// </summary> /// <param name="current">The Current object for the invocation.</param> - void ice_ping(Current current); - - /// <summary> - /// Returns the Slice type IDs of the interfaces supported by this object. - /// </summary> - /// <returns>The Slice type IDs of the interfaces supported by this object, in base-to-derived - /// order. The first element of the returned array is always ::Ice::Object.</returns> - string[] ice_ids(); + void ice_ping(Current current = null); /// <summary> /// Returns the Slice type IDs of the interfaces supported by this object. @@ -100,20 +80,14 @@ namespace Ice /// <param name="current">The Current object for the invocation.</param> /// <returns>The Slice type IDs of the interfaces supported by this object, in base-to-derived /// order. The first element of the returned array is always ::Ice::Object.</returns> - string[] ice_ids(Current current); - - /// <summary> - /// Returns the Slice type ID of the most-derived interface supported by this object. - /// </summary> - /// <returns>The Slice type ID of the most-derived interface.</returns> - string ice_id(); + string[] ice_ids(Current current = null); /// <summary> /// Returns the Slice type ID of the most-derived interface supported by this object. /// </summary> /// <param name="current">The Current object for the invocation.</param> /// <returns>The Slice type ID of the most-derived interface.</returns> - string ice_id(Current current); + string ice_id(Current current = null); /// <summary> /// The Ice run time invokes this method prior to marshaling an object's data members. This allows a subclass @@ -182,19 +156,9 @@ namespace Ice /// Tests whether this object supports a specific Slice interface. /// </summary> /// <param name="s">The type ID of the Slice interface to test against.</param> - /// <returns>The return value is true if s is ::Ice::Object.</returns> - public virtual bool ice_isA(string s) - { - return s.Equals(ids__[0]); - } - - /// <summary> - /// Tests whether this object supports a specific Slice interface. - /// </summary> - /// <param name="s">The type ID of the Slice interface to test against.</param> /// <param name="current">The Current object for the invocation.</param> /// <returns>The return value is true if s is ::Ice::Object.</returns> - public virtual bool ice_isA(string s, Current current) + public virtual bool ice_isA(string s, Current current = null) { return s.Equals(ids__[0]); } @@ -213,17 +177,9 @@ namespace Ice /// <summary> /// Tests whether this object can be reached. - /// </summary> - public virtual void ice_ping() - { - // Nothing to do. - } - - /// <summary> - /// Tests whether this object can be reached. /// <param name="current">The Current object for the invocation.</param> /// </summary> - public virtual void ice_ping(Current current) + public virtual void ice_ping(Current current = null) { // Nothing to do. } @@ -239,18 +195,9 @@ namespace Ice /// <summary> /// Returns the Slice type IDs of the interfaces supported by this object. /// </summary> - /// <returns>An array whose only element is ::Ice::Object.</returns> - public virtual string[] ice_ids() - { - return ids__; - } - - /// <summary> - /// Returns the Slice type IDs of the interfaces supported by this object. - /// </summary> /// <param name="current">The Current object for the invocation.</param> /// <returns>An array whose only element is ::Ice::Object.</returns> - public virtual string[] ice_ids(Current current) + public virtual string[] ice_ids(Current current = null) { return ids__; } @@ -268,18 +215,9 @@ namespace Ice /// <summary> /// Returns the Slice type ID of the most-derived interface supported by this object. /// </summary> - /// <returns>The return value is always ::Ice::Object.</returns> - public virtual string ice_id() - { - return ids__[0]; - } - - /// <summary> - /// Returns the Slice type ID of the most-derived interface supported by this object. - /// </summary> /// <param name="current">The Current object for the invocation.</param> /// <returns>The return value is always ::Ice::Object.</returns> - public virtual string ice_id(Current current) + public virtual string ice_id(Current current = null) { return ids__[0]; } @@ -457,8 +395,6 @@ namespace Ice } } } - - public static Ice.Current defaultCurrent = new Ice.Current(); } /// <summary> @@ -501,19 +437,34 @@ namespace Ice public abstract class BlobjectAsync : Ice.ObjectImpl { - public abstract void ice_invoke_async(AMD_Object_ice_invoke cb, byte[] inEncaps, Current current); + public abstract Task<Ice.Object_Ice_invokeResult> ice_invokeAsync(byte[] inEncaps, Current current); public override DispatchStatus dispatch__(IceInternal.Incoming inS__, Current current) { byte[] inEncaps = inS__.readParamEncaps(); - AMD_Object_ice_invoke cb = new _AMD_Object_ice_invoke(inS__); + var in__ = new IceInternal.IncomingAsync(inS__); + try { - ice_invoke_async(cb, inEncaps, current); + ice_invokeAsync(inEncaps, current).ContinueWith( + (t) => + { + try + { + var ret__ = t.Result; + in__.writeParamEncaps__(ret__.outEncaps, ret__.returnValue); + } + catch(AggregateException ae) + { + in__.exception__(ae.InnerException); + return; + } + in__.response__(); + }); } catch(System.Exception ex) { - cb.ice_exception(ex); + in__.ice_exception(ex); } return DispatchStatus.DispatchAsync; } diff --git a/csharp/src/Ice/OutgoingAsync.cs b/csharp/src/Ice/OutgoingAsync.cs index db48881c593..887a31e03eb 100644 --- a/csharp/src/Ice/OutgoingAsync.cs +++ b/csharp/src/Ice/OutgoingAsync.cs @@ -54,7 +54,7 @@ namespace IceInternal // try { - instance_.clientThreadPool().dispatch(this.invokeSent, cachedConnection_); + instance_.clientThreadPool().dispatch(invokeSent, cachedConnection_); } catch(Ice.CommunicatorDestroyedException) { @@ -67,7 +67,7 @@ namespace IceInternal // CommunicatorDestroyedCompleted is the only exception that can propagate directly // from this method. // - instance_.clientThreadPool().dispatch(this.invokeException, cachedConnection_); + instance_.clientThreadPool().dispatch(invokeException, cachedConnection_); } public void invokeResponseAsync() @@ -76,7 +76,7 @@ namespace IceInternal // CommunicatorDestroyedCompleted is the only exception that can propagate directly // from this method. // - instance_.clientThreadPool().dispatch(this.invokeResponse, cachedConnection_); + instance_.clientThreadPool().dispatch(invokeResponse, cachedConnection_); } public void invokeSent() @@ -1059,7 +1059,7 @@ namespace IceInternal if(is_ == null || is_.isEmpty()) { // - // If there's no response (oneway, batch-oneway proxies), we just set the promise + // If there's no response (oneway, batch-oneway proxies), we just set the result // on completion without reading anything from the input stream. This is required for // batch invocations. // diff --git a/csharp/src/Ice/Patcher.cs b/csharp/src/Ice/Patcher.cs index 947602f247d..fbe52466fca 100644 --- a/csharp/src/Ice/Patcher.cs +++ b/csharp/src/Ice/Patcher.cs @@ -25,7 +25,7 @@ namespace IceInternal { if(v != null && !typeof(T).IsAssignableFrom(v.GetType())) { - IceInternal.Ex.throwUOE(_type, v.ice_id()); + Ex.throwUOE(_type, v.ice_id()); } value = (T)v; } @@ -50,7 +50,7 @@ namespace IceInternal { if(v != null && !typeof(T).IsAssignableFrom(v.GetType())) { - IceInternal.Ex.throwUOE(_type, v.ice_id()); + Ex.throwUOE(_type, v.ice_id()); } InvokeInfo info = getInvokeInfo(_seqType); @@ -199,7 +199,7 @@ namespace IceInternal { if(v != null && !typeof(T).IsAssignableFrom(v.GetType())) { - IceInternal.Ex.throwUOE(_type, v.ice_id()); + Ex.throwUOE(_type, v.ice_id()); } _seq[_index] = (T)v; @@ -223,7 +223,7 @@ namespace IceInternal { if(v != null && !typeof(T).IsAssignableFrom(v.GetType())) { - IceInternal.Ex.throwUOE(_type, v.ice_id()); + Ex.throwUOE(_type, v.ice_id()); } int count = _seq.Count; diff --git a/csharp/src/Ice/PropertiesAdminI.cs b/csharp/src/Ice/PropertiesAdminI.cs index 3f05060f48b..951c70d620d 100644 --- a/csharp/src/Ice/PropertiesAdminI.cs +++ b/csharp/src/Ice/PropertiesAdminI.cs @@ -7,6 +7,7 @@ // // ********************************************************************** +using System; using System.Collections.Generic; namespace Ice @@ -47,9 +48,10 @@ namespace IceInternal return _properties.getPropertiesForPrefix(name); } - public override void setProperties_async(Ice.AMD_PropertiesAdmin_setProperties cb, - Dictionary<string, string> props, - Ice.Current current) + public override void setPropertiesAsync(Dictionary<string, string> props, + Action response, + Action<Exception> exception, + Ice.Current current) { lock(this) { @@ -180,7 +182,7 @@ namespace IceInternal // // Send the response now so that we do not block the client during the call to the update callback. // - cb.ice_response(); + response(); if(_updateCallbacks.Count > 0) { @@ -199,7 +201,7 @@ namespace IceInternal { changes.Add(e.Key, e.Value); } - + foreach(Ice.PropertiesAdminUpdateCallback callback in callbacks) { try diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index 65f5aee516f..6d8b4ee69d2 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -774,6 +774,12 @@ namespace Ice /// </summary> public struct Object_Ice_invokeResult { + public Object_Ice_invokeResult(bool returnValue, byte[] outEncaps) + { + this.returnValue = returnValue; + this.outEncaps = outEncaps; + } + /// <summary> /// If the operation completed successfully, the return value /// is true. If the operation raises a user exception, diff --git a/csharp/src/Ice/RouterInfo.cs b/csharp/src/Ice/RouterInfo.cs index cfb7645d598..1a5fe9b0131 100644 --- a/csharp/src/Ice/RouterInfo.cs +++ b/csharp/src/Ice/RouterInfo.cs @@ -95,15 +95,18 @@ namespace IceInternal return; } - _router.begin_getClientProxy().whenCompleted( - (Ice.ObjectPrx proxy) => + _router.getClientProxyAsync().ContinueWith( + (t) => { - callback.setEndpoints(setClientEndpoints(proxy)); - }, - (Ice.Exception ex) => - { - Debug.Assert(ex is Ice.LocalException); - callback.setException((Ice.LocalException)ex); + try + { + callback.setEndpoints(setClientEndpoints(t.Result)); + } + catch(System.AggregateException ae) + { + Debug.Assert(ae.InnerException is Ice.LocalException); + callback.setException((Ice.LocalException)ae.InnerException); + } }); } @@ -151,18 +154,21 @@ namespace IceInternal return true; } } - _router.begin_addProxies(new Ice.ObjectPrx[] { proxy }).whenCompleted( - (Ice.ObjectPrx[] evictedProxies) => - { - addAndEvictProxies(proxy, evictedProxies); - callback.addedProxy(); - }, - (Ice.Exception ex) => + + _router.addProxiesAsync(new Ice.ObjectPrx[] { proxy }).ContinueWith( + (t) => { - Debug.Assert(ex is Ice.LocalException); - callback.setException((Ice.LocalException)ex); + try + { + addAndEvictProxies(proxy, t.Result); + callback.addedProxy(); + } + catch(System.AggregateException ae) + { + Debug.Assert(ae.InnerException is Ice.LocalException); + callback.setException((Ice.LocalException)ae.InnerException); + } }); - return false; } diff --git a/csharp/src/Ice/ThreadPool.cs b/csharp/src/Ice/ThreadPool.cs index d42b087f82b..8a0b46e8a0a 100644 --- a/csharp/src/Ice/ThreadPool.cs +++ b/csharp/src/Ice/ThreadPool.cs @@ -378,7 +378,7 @@ namespace IceInternal { dispatchFromThisThread(call, con); }); - System.Threading.Monitor.Pulse(this); + Monitor.Pulse(this); // // If this is a dynamic thread pool which can still grow and if all threads are diff --git a/csharp/src/Ice/msbuild/ice.csproj b/csharp/src/Ice/msbuild/ice.csproj index 8a81c87b010..3e5f519015e 100644 --- a/csharp/src/Ice/msbuild/ice.csproj +++ b/csharp/src/Ice/msbuild/ice.csproj @@ -26,9 +26,6 @@ <Compile Include="..\ACM.cs"> <Link>ACM.cs</Link> </Compile> - <Compile Include="..\AMDCallback.cs"> - <Link>AMDCallback.cs</Link> - </Compile> <Compile Include="..\Application.cs"> <Link>Application.cs</Link> </Compile> @@ -471,7 +468,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceBox/ServiceManagerI.cs b/csharp/src/IceBox/ServiceManagerI.cs index badb590bcce..eaaf1bb8a30 100644 --- a/csharp/src/IceBox/ServiceManagerI.cs +++ b/csharp/src/IceBox/ServiceManagerI.cs @@ -10,7 +10,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Threading; +using System.Threading.Tasks; using System.Diagnostics; namespace IceBox @@ -242,7 +242,7 @@ class ServiceManagerI : ServiceManagerDisp_ if(activeServices.Count > 0) { - observer.begin_servicesStarted(activeServices.ToArray(), this.observerCompleted, null); + observer.servicesStartedAsync(activeServices.ToArray()).ContinueWith((t) => observerCompleted(observer, t)); } } @@ -810,7 +810,7 @@ class ServiceManagerI : ServiceManagerDisp_ foreach(ServiceObserverPrx observer in observers) { - observer.begin_servicesStarted(servicesArray, this.observerCompleted, null); + observer.servicesStartedAsync(servicesArray).ContinueWith((t) => observerCompleted(observer, t)); } } } @@ -827,26 +827,25 @@ class ServiceManagerI : ServiceManagerDisp_ foreach(ServiceObserverPrx observer in observers) { - observer.begin_servicesStopped(servicesArray, this.observerCompleted, null); + observer.servicesStoppedAsync(servicesArray).ContinueWith((t) => observerCompleted(observer, t)); } } } private void - observerCompleted(Ice.AsyncResult result) + observerCompleted(ServiceObserverPrx observer, Task t) { try { - result.throwLocalException(); + t.Wait(); } - catch(Ice.LocalException ex) + catch(AggregateException ae) { lock(this) { - ServiceObserverPrx observer = ServiceObserverPrxHelper.uncheckedCast(result.getProxy()); if(_observers.Remove(observer)) { - observerRemoved(observer, ex); + observerRemoved(observer, ae.InnerException); } } } diff --git a/csharp/src/IceBox/msbuild/icebox/icebox.csproj b/csharp/src/IceBox/msbuild/icebox/icebox.csproj index 6de53617b8a..3f6c7ddf13d 100644 --- a/csharp/src/IceBox/msbuild/icebox/icebox.csproj +++ b/csharp/src/IceBox/msbuild/icebox/icebox.csproj @@ -57,7 +57,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceBox/msbuild/iceboxlib/iceboxlib.csproj b/csharp/src/IceBox/msbuild/iceboxlib/iceboxlib.csproj index 6faafe69caa..40b0fac20e6 100644 --- a/csharp/src/IceBox/msbuild/iceboxlib/iceboxlib.csproj +++ b/csharp/src/IceBox/msbuild/iceboxlib/iceboxlib.csproj @@ -45,7 +45,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceDiscovery/LocatorI.cs b/csharp/src/IceDiscovery/LocatorI.cs index 62cf585e36a..a1cebf66480 100644 --- a/csharp/src/IceDiscovery/LocatorI.cs +++ b/csharp/src/IceDiscovery/LocatorI.cs @@ -21,10 +21,8 @@ namespace IceDiscovery } public override void - setAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setAdapterDirectProxy cb, - string adapterId, - Ice.ObjectPrx proxy, - Ice.Current current) + setAdapterDirectProxyAsync(string adapterId, Ice.ObjectPrx proxy, Action response, + Action<Exception> exception, Ice.Current current) { lock(this) { @@ -36,16 +34,13 @@ namespace IceDiscovery { _adapters.Remove(adapterId); } - cb.ice_response(); + response(); } } public override void - setReplicatedAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setReplicatedAdapterDirectProxy cb, - string adapterId, - string replicaGroupId, - Ice.ObjectPrx proxy, - Ice.Current current) + setReplicatedAdapterDirectProxyAsync(string adapterId, string replicaGroupId, Ice.ObjectPrx proxy, + Action response, Action<Exception> exception, Ice.Current current) { lock(this) { @@ -74,16 +69,14 @@ namespace IceDiscovery } } } - cb.ice_response(); + response(); } public override void - setServerProcessProxy_async(Ice.AMD_LocatorRegistry_setServerProcessProxy cb, - string id, - Ice.ProcessPrx process, - Ice.Current current) + setServerProcessProxyAsync(string id, Ice.ProcessPrx process, Action response, Action<Exception> exception, + Ice.Current current) { - cb.ice_response(); + response(); } internal Ice.ObjectPrx findObject(Ice.Identity id) @@ -189,14 +182,18 @@ namespace IceDiscovery _registry = registry; } - public override void findObjectById_async(Ice.AMD_Locator_findObjectById cb, Ice.Identity id, Ice.Current c) + public override void + findObjectByIdAsync(Ice.Identity id, Action<Ice.ObjectPrx> response, Action<Exception> exception, + Ice.Current current) { - _lookup.findObject(cb, id); + _lookup.findObject(id, response); } - public override void findAdapterById_async(Ice.AMD_Locator_findAdapterById cb, string adapterId, Ice.Current c) + public override void + findAdapterByIdAsync(string adapterId, Action<Ice.ObjectPrx> response, Action<Exception> exception, + Ice.Current current) { - _lookup.findAdapter(cb, adapterId); + _lookup.findAdapter(adapterId, response); } public override Ice.LocatorRegistryPrx getRegistry(Ice.Current current) diff --git a/csharp/src/IceDiscovery/LookupI.cs b/csharp/src/IceDiscovery/LookupI.cs index 233c1a2128b..a9a84b3aeb2 100644 --- a/csharp/src/IceDiscovery/LookupI.cs +++ b/csharp/src/IceDiscovery/LookupI.cs @@ -12,7 +12,7 @@ namespace IceDiscovery using System; using System.Collections.Generic; - class Request<T, AmdCB> + class Request<T> { protected Request(LookupI lookup, T id, int retryCount) { @@ -26,7 +26,7 @@ namespace IceDiscovery return _id; } - public bool addCallback(AmdCB cb) + public bool addCallback(Action<Ice.ObjectPrx> cb) { callbacks_.Add(cb); return callbacks_.Count == 1; @@ -39,16 +39,16 @@ namespace IceDiscovery protected LookupI lookup_; protected int nRetry_; - protected List<AmdCB> callbacks_ = new List<AmdCB>(); + protected List<Action<Ice.ObjectPrx>> callbacks_ = new List<Action<Ice.ObjectPrx>>(); private T _id; }; - class AdapterRequest : Request<string, Ice.AMD_Locator_findAdapterById>, IceInternal.TimerTask + class AdapterRequest : Request<string>, IceInternal.TimerTask { public AdapterRequest(LookupI lookup, string id, int retryCount) : base(lookup, id, retryCount) { - _start = System.DateTime.Now.Ticks; + _start = DateTime.Now.Ticks; } public override bool retry() @@ -63,7 +63,7 @@ namespace IceDiscovery _proxies.Add(proxy); if(_latency == 0) { - _latency = (long)((System.DateTime.Now.Ticks - _start) * lookup_.latencyMultiplier() / 10000.0); + _latency = (long)((DateTime.Now.Ticks - _start) * lookup_.latencyMultiplier() / 10000.0); if(_latency == 0) { _latency = 1; // 1ms @@ -110,9 +110,9 @@ namespace IceDiscovery private void sendResponse(Ice.ObjectPrx proxy) { - foreach(Ice.AMD_Locator_findAdapterById cb in callbacks_) + foreach(var cb in callbacks_) { - cb.ice_response(proxy); + cb(proxy); } callbacks_.Clear(); } @@ -122,7 +122,7 @@ namespace IceDiscovery private long _latency; }; - class ObjectRequest : Request<Ice.Identity, Ice.AMD_Locator_findObjectById>, IceInternal.TimerTask + class ObjectRequest : Request<Ice.Identity>, IceInternal.TimerTask { public ObjectRequest(LookupI lookup, Ice.Identity id, int retryCount) : base(lookup, id, retryCount) { @@ -135,9 +135,9 @@ namespace IceDiscovery public void finished(Ice.ObjectPrx proxy) { - foreach(Ice.AMD_Locator_findObjectById cb in callbacks_) + foreach(var cb in callbacks_) { - cb.ice_response(proxy); + cb(proxy); } callbacks_.Clear(); } @@ -166,8 +166,8 @@ namespace IceDiscovery _lookupReply = lookupReply; } - public override void findObjectById(string domainId, Ice.Identity id, IceDiscovery.LookupReplyPrx reply, - Ice.Current c) + public override void findObjectById(string domainId, Ice.Identity id, LookupReplyPrx reply, + Ice.Current current) { if(!domainId.Equals(_domainId)) { @@ -182,7 +182,7 @@ namespace IceDiscovery // try { - reply.begin_foundObjectById(id, proxy); + reply.foundObjectByIdAsync(id, proxy); } catch(Ice.LocalException) { @@ -191,8 +191,8 @@ namespace IceDiscovery } } - public override void findAdapterById(string domainId, string adapterId, IceDiscovery.LookupReplyPrx reply, - Ice.Current c) + public override void findAdapterById(string domainId, string adapterId, LookupReplyPrx reply, + Ice.Current current) { if(!domainId.Equals(_domainId)) { @@ -208,7 +208,7 @@ namespace IceDiscovery // try { - reply.begin_foundAdapterById(adapterId, proxy, isReplicaGroup); + reply.foundAdapterByIdAsync(adapterId, proxy, isReplicaGroup); } catch(Ice.LocalException) { @@ -217,7 +217,7 @@ namespace IceDiscovery } } - internal void findObject(Ice.AMD_Locator_findObjectById cb, Ice.Identity id) + internal void findObject(Ice.Identity id, Action<Ice.ObjectPrx> response) { lock(this) { @@ -227,11 +227,12 @@ namespace IceDiscovery request = new ObjectRequest(this, id, _retryCount); _objectRequests.Add(id, request); } - if(request.addCallback(cb)) + + if(request.addCallback(response)) { try { - _lookup.begin_findObjectById(_domainId, id, _lookupReply); + _lookup.findObjectByIdAsync(_domainId, id, _lookupReply); _timer.schedule(request, _timeout); } catch(Ice.LocalException) @@ -243,7 +244,7 @@ namespace IceDiscovery } } - internal void findAdapter(Ice.AMD_Locator_findAdapterById cb, string adapterId) + internal void findAdapter(string adapterId, Action<Ice.ObjectPrx> response) { lock(this) { @@ -253,11 +254,12 @@ namespace IceDiscovery request = new AdapterRequest(this, adapterId, _retryCount); _adapterRequests.Add(adapterId, request); } - if(request.addCallback(cb)) + + if(request.addCallback(response)) { try { - _lookup.begin_findAdapterById(_domainId, adapterId, _lookupReply); + _lookup.findAdapterByIdAsync(_domainId, adapterId, _lookupReply); _timer.schedule(request, _timeout); } catch(Ice.LocalException) @@ -316,7 +318,7 @@ namespace IceDiscovery { try { - _lookup.begin_findObjectById(_domainId, request.getId(), _lookupReply); + _lookup.findObjectByIdAsync(_domainId, request.getId(), _lookupReply); _timer.schedule(request, _timeout); return; } @@ -345,7 +347,7 @@ namespace IceDiscovery { try { - _lookup.begin_findAdapterById(_domainId, request.getId(), _lookupReply); + _lookup.findAdapterByIdAsync(_domainId, request.getId(), _lookupReply); _timer.schedule(request, _timeout); return; } diff --git a/csharp/src/IceDiscovery/msbuild/icediscovery.csproj b/csharp/src/IceDiscovery/msbuild/icediscovery.csproj index f4e9bfc197b..033ff4b039f 100644 --- a/csharp/src/IceDiscovery/msbuild/icediscovery.csproj +++ b/csharp/src/IceDiscovery/msbuild/icediscovery.csproj @@ -54,7 +54,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceGrid/msbuild/icegrid.csproj b/csharp/src/IceGrid/msbuild/icegrid.csproj index da9ad984f5e..c6d20ef1d40 100644 --- a/csharp/src/IceGrid/msbuild/icegrid.csproj +++ b/csharp/src/IceGrid/msbuild/icegrid.csproj @@ -78,7 +78,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceLocatorDiscovery/PluginI.cs b/csharp/src/IceLocatorDiscovery/PluginI.cs index 9f3a9a99a1c..7597b78555d 100644 --- a/csharp/src/IceLocatorDiscovery/PluginI.cs +++ b/csharp/src/IceLocatorDiscovery/PluginI.cs @@ -11,8 +11,7 @@ namespace IceLocatorDiscovery { using System; using System.Collections.Generic; - using System.Diagnostics; - using System.Text; + using System.Threading.Tasks; public sealed class PluginFactory : Ice.PluginFactory { @@ -23,21 +22,19 @@ namespace IceLocatorDiscovery } } - internal class Request + internal class Request : TaskCompletionSource<Ice.Object_Ice_invokeResult> { public Request(LocatorI locator, string operation, Ice.OperationMode mode, byte[] inParams, - Dictionary<string, string> context, - Ice.AMD_Object_ice_invoke amdCB) + Dictionary<string, string> context) { _locator = locator; _operation = operation; _mode = mode; _inParams = inParams; _context = context; - _amdCB = amdCB; } public void @@ -46,14 +43,17 @@ namespace IceLocatorDiscovery _locatorPrx = l; try { - l.begin_ice_invoke(_operation, _mode, _inParams, _context).whenCompleted( - (bool ok, byte[] outParams) => + l.ice_invokeAsync(_operation, _mode, _inParams, _context).ContinueWith( + (task) => { - _amdCB.ice_response(ok, outParams); - }, - (Ice.Exception ex) => - { - exception(ex); + try + { + SetResult(task.Result); + } + catch(AggregateException ae) + { + SetException(ae.InnerException); + } }); } catch(Ice.LocalException ex) @@ -71,23 +71,23 @@ namespace IceLocatorDiscovery } catch(Ice.RequestFailedException exc) { - _amdCB.ice_exception(exc); + SetException(exc); } catch(Ice.UnknownException exc) { - _amdCB.ice_exception(exc); + SetException(exc); } catch(Ice.NoEndpointException) { - _amdCB.ice_exception(new Ice.ObjectNotExistException()); + SetException(new Ice.ObjectNotExistException()); } catch(Ice.ObjectAdapterDeactivatedException) { - _amdCB.ice_exception(new Ice.ObjectNotExistException()); + SetException(new Ice.ObjectNotExistException()); } catch(Ice.CommunicatorDestroyedException) { - _amdCB.ice_exception(new Ice.ObjectNotExistException()); + SetException(new Ice.ObjectNotExistException()); } catch(Ice.Exception) { @@ -100,7 +100,6 @@ namespace IceLocatorDiscovery private readonly Ice.OperationMode _mode; private readonly Dictionary<string, string> _context; private readonly byte[] _inParams; - private readonly Ice.AMD_Object_ice_invoke _amdCB; private Ice.LocatorPrx _locatorPrx; } @@ -108,15 +107,17 @@ namespace IceLocatorDiscovery internal class VoidLocatorI : Ice.LocatorDisp_ { public override void - findObjectById_async(Ice.AMD_Locator_findObjectById amdCB, Ice.Identity id, Ice.Current current) + findObjectByIdAsync(Ice.Identity id, Action<Ice.ObjectPrx> response, Action<Exception> exception, + Ice.Current current) { - amdCB.ice_response(null); + response(null); } public override void - findAdapterById_async(Ice.AMD_Locator_findAdapterById amdCB, String id, Ice.Current current) + findAdapterByIdAsync(string id, Action<Ice.ObjectPrx> response, Action<Exception> exception, + Ice.Current current) { - amdCB.ice_response(null); + response(null); } public override Ice.LocatorRegistryPrx @@ -149,12 +150,14 @@ namespace IceLocatorDiscovery _lookupReply = lookupReply; } - public override void - ice_invoke_async(Ice.AMD_Object_ice_invoke amdCB, byte[] inParams, Ice.Current current) + public override Task<Ice.Object_Ice_invokeResult> + ice_invokeAsync(byte[] inParams, Ice.Current current) { lock(this) { - invoke(null, new Request(this, current.operation, current.mode, inParams, current.ctx, amdCB)); + var request = new Request(this, current.operation, current.mode, inParams, current.ctx); + invoke(null, request); + return request.Task; } } @@ -269,7 +272,7 @@ namespace IceLocatorDiscovery _pendingRetryCount = _retryCount; try { - _lookup.begin_findLocator(_instanceName, _lookupReply); // Send multicast request. + _lookup.findLocatorAsync(_instanceName, _lookupReply); // Send multicast request. _timer.schedule(this, _timeout); } catch(Ice.LocalException) @@ -295,7 +298,7 @@ namespace IceLocatorDiscovery { try { - _lookup.begin_findLocator(_instanceName, _lookupReply); // Send multicast request + _lookup.findLocatorAsync(_instanceName, _lookupReply); // Send multicast request _timer.schedule(this, _timeout); return; } diff --git a/csharp/src/IceLocatorDiscovery/msbuild/icelocatordiscovery.csproj b/csharp/src/IceLocatorDiscovery/msbuild/icelocatordiscovery.csproj index 2f0f56c12a4..7c9ec6e28c8 100644 --- a/csharp/src/IceLocatorDiscovery/msbuild/icelocatordiscovery.csproj +++ b/csharp/src/IceLocatorDiscovery/msbuild/icelocatordiscovery.csproj @@ -48,7 +48,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IcePatch2/msbuild/icepatch2.csproj b/csharp/src/IcePatch2/msbuild/icepatch2.csproj index bfbc9ff2f12..ab798f96158 100644 --- a/csharp/src/IcePatch2/msbuild/icepatch2.csproj +++ b/csharp/src/IcePatch2/msbuild/icepatch2.csproj @@ -49,7 +49,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceSSL/msbuild/icessl.csproj b/csharp/src/IceSSL/msbuild/icessl.csproj index 984baf2d4ea..be538a53458 100644 --- a/csharp/src/IceSSL/msbuild/icessl.csproj +++ b/csharp/src/IceSSL/msbuild/icessl.csproj @@ -82,7 +82,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> diff --git a/csharp/src/IceStorm/msbuild/icestorm.csproj b/csharp/src/IceStorm/msbuild/icestorm.csproj index 88f11db2c70..0f065dac337 100644 --- a/csharp/src/IceStorm/msbuild/icestorm.csproj +++ b/csharp/src/IceStorm/msbuild/icestorm.csproj @@ -49,7 +49,6 @@ <PropertyGroup Label="IceBuilder"> <IceBuilderIncludeDirectories>$(IceHome)\slice</IceBuilderIncludeDirectories> <IceBuilderAllowIcePrefix>yes</IceBuilderAllowIcePrefix> - <IceBuilderAdditionalOptions>--compat</IceBuilderAdditionalOptions> </PropertyGroup> <Import Project="$(IceBuilderCsharpTargets)" Condition="Exists('$(IceBuilderCsharpTargets)')" /> </Project> |