http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs deleted file mode 100644 index 23cae6b..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyCollection.cs +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Collections -{ - using System; - using System.Collections; - using System.Collections.Generic; - - /// <summary> - /// Read-only wrapper over ICollection{T}. - /// </summary> - internal struct ReadOnlyCollection<T> : ICollection<T> - { - /** Wrapped collection. */ - private readonly ICollection<T> _col; - - /// <summary> - /// Initializes a new instance of the <see cref="ReadOnlyCollection{T}"/> class. - /// </summary> - public ReadOnlyCollection(ICollection<T> col) - { - _col = col; - } - - /** <inheritdoc /> */ - public IEnumerator<T> GetEnumerator() - { - return _col.GetEnumerator(); - } - - /** <inheritdoc /> */ - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable) _col).GetEnumerator(); - } - - /** <inheritdoc /> */ - public void Add(T item) - { - throw GetReadOnlyException(); - } - - /** <inheritdoc /> */ - public void Clear() - { - throw GetReadOnlyException(); - } - - /** <inheritdoc /> */ - public bool Contains(T item) - { - return _col.Contains(item); - } - - /** <inheritdoc /> */ - public void CopyTo(T[] array, int arrayIndex) - { - _col.CopyTo(array, arrayIndex); - } - - /** <inheritdoc /> */ - public bool Remove(T item) - { - throw GetReadOnlyException(); - } - - /** <inheritdoc /> */ - public int Count - { - get { return _col.Count; } - } - - /** <inheritdoc /> */ - public bool IsReadOnly - { - get { return true; } - } - - /// <summary> - /// Gets the readonly exception. - /// </summary> - private static Exception GetReadOnlyException() - { - return new NotSupportedException("Collection is read-only."); - } - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs deleted file mode 100644 index 60ec9d0..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Collections -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Diagnostics; - - /// <summary> - /// Read-only wrapper over IDictionary{K, V}. - /// </summary> - internal struct ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue> - { - /** Inner dict. */ - private readonly IDictionary<TKey, TValue> _dict; - - /// <summary> - /// Initializes a new instance of the <see cref="ReadOnlyDictionary{K, V}"/> class. - /// </summary> - /// <param name="dict">The dictionary to wrap.</param> - public ReadOnlyDictionary(IDictionary<TKey, TValue> dict) - { - Debug.Assert(dict != null); - - _dict = dict; - } - - /** <inheritdoc /> */ - public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() - { - return _dict.GetEnumerator(); - } - - /** <inheritdoc /> */ - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable) _dict).GetEnumerator(); - } - - /** <inheritdoc /> */ - public void Add(KeyValuePair<TKey, TValue> item) - { - throw GetReadonlyException(); - } - - /** <inheritdoc /> */ - public void Clear() - { - throw GetReadonlyException(); - } - - /** <inheritdoc /> */ - public bool Contains(KeyValuePair<TKey, TValue> item) - { - return _dict.Contains(item); - } - - /** <inheritdoc /> */ - public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) - { - _dict.CopyTo(array, arrayIndex); - } - - /** <inheritdoc /> */ - public bool Remove(KeyValuePair<TKey, TValue> item) - { - throw GetReadonlyException(); - } - - /** <inheritdoc /> */ - public int Count - { - get { return _dict.Count; } - } - - /** <inheritdoc /> */ - public bool IsReadOnly - { - get { return true; } - } - - /** <inheritdoc /> */ - public bool ContainsKey(TKey key) - { - return _dict.ContainsKey(key); - } - - /** <inheritdoc /> */ - public void Add(TKey key, TValue value) - { - throw GetReadonlyException(); - } - - /** <inheritdoc /> */ - public bool Remove(TKey key) - { - return _dict.Remove(key); - } - - /** <inheritdoc /> */ - public bool TryGetValue(TKey key, out TValue value) - { - return _dict.TryGetValue(key, out value); - } - - /** <inheritdoc /> */ - public TValue this[TKey key] - { - get { return _dict[key]; } - set { throw GetReadonlyException(); } - } - - /** <inheritdoc /> */ - public ICollection<TKey> Keys - { - get { return _dict.Keys; } - } - - /** <inheritdoc /> */ - public ICollection<TValue> Values - { - get { return _dict.Values; } - } - - /// <summary> - /// Gets the readonly exception. - /// </summary> - private static Exception GetReadonlyException() - { - return new NotSupportedException("Dictionary is read-only."); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs deleted file mode 100644 index 4e5c396..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using Apache.Ignite.Core.Common; - - /// <summary> - /// Adapts IGridFuture to the IAsyncResult. - /// </summary> - [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", - Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " + - "to the client, and IAsyncResult is not IDisposable.")] - public class AsyncResult : IAsyncResult - { - /** */ - private readonly ManualResetEvent _waitHandle; - - /// <summary> - /// Initializes a new instance of the <see cref="AsyncResult"/> class. - /// </summary> - /// <param name="fut">The future to wrap.</param> - public AsyncResult(IFuture fut) - { - _waitHandle = new ManualResetEvent(false); - - fut.Listen(() => _waitHandle.Set()); - } - - /** <inheritdoc /> */ - public bool IsCompleted - { - get { return _waitHandle.WaitOne(0); } - } - - /** <inheritdoc /> */ - public WaitHandle AsyncWaitHandle - { - get { return _waitHandle; } - } - - /** <inheritdoc /> */ - public object AsyncState - { - get { return null; } - } - - /** <inheritdoc /> */ - public bool CompletedSynchronously - { - get { return false; } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs deleted file mode 100644 index 14195fd..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - - /// <summary> - /// Represents an IAsyncResult that is completed. - /// </summary> - [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", - Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " + - "to the client, and IAsyncResult is not IDisposable.")] - public class CompletedAsyncResult : IAsyncResult - { - /** Singleton instance. */ - public static readonly IAsyncResult Instance = new CompletedAsyncResult(); - - /** */ - private readonly WaitHandle _asyncWaitHandle = new ManualResetEvent(true); - - /// <summary> - /// Prevents a default instance of the <see cref="CompletedAsyncResult"/> class from being created. - /// </summary> - private CompletedAsyncResult() - { - // No-op. - } - - /** <inheritdoc /> */ - public bool IsCompleted - { - get { return true; } - } - - /** <inheritdoc /> */ - public WaitHandle AsyncWaitHandle - { - get { return _asyncWaitHandle; } - } - - /** <inheritdoc /> */ - public object AsyncState - { - get { return null; } - } - - /** <inheritdoc /> */ - public bool CompletedSynchronously - { - get { return false; } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs deleted file mode 100644 index fa785b2..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/CopyOnWriteConcurrentDictionary.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Collections.Generic; - - /// <summary> - /// Concurrent dictionary with CopyOnWrite mechanism inside. - /// Good for frequent reads / infrequent writes scenarios. - /// </summary> - public class CopyOnWriteConcurrentDictionary<TKey, TValue> - { - /** */ - private volatile Dictionary<TKey, TValue> _dict = new Dictionary<TKey, TValue>(); - - /// <summary> - /// Gets the value associated with the specified key. - /// </summary> - /// <param name="key">The key.</param> - /// <param name="val">The value.</param> - /// <returns>true if the dictionary contains an element with the specified key; otherwise, false.</returns> - public bool TryGetValue(TKey key, out TValue val) - { - return _dict.TryGetValue(key, out val); - } - - /// <summary> - /// Adds a key/value pair if the key does not already exist. - /// </summary> - /// <param name="key">The key.</param> - /// <param name="valueFactory">The function used to generate a value for the key.</param> - /// <returns>The value for the key.</returns> - public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory) - { - lock (this) - { - TValue res; - - if (_dict.TryGetValue(key, out res)) - return res; - - var dict0 = new Dictionary<TKey, TValue>(_dict); - - res = valueFactory(key); - - dict0[key] = res; - - _dict = dict0; - - return res; - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs deleted file mode 100644 index 7f83588..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Diagnostics; - using System.Linq.Expressions; - using System.Reflection; - using System.Reflection.Emit; - - /// <summary> - /// Converts generic and non-generic delegates. - /// </summary> - public static class DelegateConverter - { - /** */ - private const string DefaultMethodName = "Invoke"; - - /// <summary> - /// Compiles a function without arguments. - /// </summary> - /// <param name="targetType">Type of the target.</param> - /// <returns>Compiled function that calls specified method on specified target.</returns> - public static Func<object, object> CompileFunc(Type targetType) - { - var method = targetType.GetMethod(DefaultMethodName); - - var targetParam = Expression.Parameter(typeof(object)); - var targetParamConverted = Expression.Convert(targetParam, targetType); - - var callExpr = Expression.Call(targetParamConverted, method); - var convertResultExpr = Expression.Convert(callExpr, typeof(object)); - - return Expression.Lambda<Func<object, object>>(convertResultExpr, targetParam).Compile(); - } - - /// <summary> - /// Compiles a function with arbitrary number of arguments. - /// </summary> - /// <typeparam name="T">Resulting delegate type.</typeparam> - /// <param name="targetType">Type of the target.</param> - /// <param name="argTypes">Argument types.</param> - /// <param name="convertToObject"> - /// Flags that indicate whether func params and/or return value should be converted from/to object. - /// </param> - /// <param name="methodName">Name of the method.</param> - /// <returns> - /// Compiled function that calls specified method on specified target. - /// </returns> - public static T CompileFunc<T>(Type targetType, Type[] argTypes, bool[] convertToObject = null, - string methodName = null) - where T : class - { - var method = targetType.GetMethod(methodName ?? DefaultMethodName, argTypes); - - return CompileFunc<T>(targetType, method, argTypes, convertToObject); - } - - /// <summary> - /// Compiles a function with arbitrary number of arguments. - /// </summary> - /// <typeparam name="T">Resulting delegate type.</typeparam> - /// <param name="method">Method.</param> - /// <param name="targetType">Type of the target.</param> - /// <param name="argTypes">Argument types.</param> - /// <param name="convertToObject"> - /// Flags that indicate whether func params and/or return value should be converted from/to object. - /// </param> - /// <returns> - /// Compiled function that calls specified method on specified target. - /// </returns> - public static T CompileFunc<T>(Type targetType, MethodInfo method, Type[] argTypes, - bool[] convertToObject = null) - where T : class - { - if (argTypes == null) - { - var args = method.GetParameters(); - argTypes = new Type[args.Length]; - - for (int i = 0; i < args.Length; i++) - argTypes[i] = args[i].ParameterType; - } - - Debug.Assert(convertToObject == null || (convertToObject.Length == argTypes.Length + 1)); - Debug.Assert(method != null); - - targetType = method.IsStatic ? null : (targetType ?? method.DeclaringType); - - var targetParam = Expression.Parameter(typeof(object)); - - Expression targetParamConverted = null; - ParameterExpression[] argParams; - int argParamsOffset = 0; - - if (targetType != null) - { - targetParamConverted = Expression.Convert(targetParam, targetType); - argParams = new ParameterExpression[argTypes.Length + 1]; - argParams[0] = targetParam; - argParamsOffset = 1; - } - else - argParams = new ParameterExpression[argTypes.Length]; // static method - - var argParamsConverted = new Expression[argTypes.Length]; - - for (var i = 0; i < argTypes.Length; i++) - { - if (convertToObject == null || convertToObject[i]) - { - var argParam = Expression.Parameter(typeof (object)); - argParams[i + argParamsOffset] = argParam; - argParamsConverted[i] = Expression.Convert(argParam, argTypes[i]); - } - else - { - var argParam = Expression.Parameter(argTypes[i]); - argParams[i + argParamsOffset] = argParam; - argParamsConverted[i] = argParam; - } - } - - Expression callExpr = Expression.Call(targetParamConverted, method, argParamsConverted); - - if (convertToObject == null || convertToObject[argTypes.Length]) - callExpr = Expression.Convert(callExpr, typeof(object)); - - return Expression.Lambda<T>(callExpr, argParams).Compile(); - } - - /// <summary> - /// Compiles a generic ctor with arbitrary number of arguments. - /// </summary> - /// <typeparam name="T">Result func type.</typeparam> - /// <param name="type">Type to be created by ctor.</param> - /// <param name="argTypes">Argument types.</param> - /// <param name="convertResultToObject">if set to <c>true</c> [convert result to object]. - /// Flag that indicates whether ctor return value should be converted to object. - /// </param> - /// <returns> - /// Compiled generic constructor. - /// </returns> - public static T CompileCtor<T>(Type type, Type[] argTypes, bool convertResultToObject = true) - { - var ctor = type.GetConstructor(argTypes); - - Debug.Assert(ctor != null); - - var args = new ParameterExpression[argTypes.Length]; - var argsConverted = new Expression[argTypes.Length]; - - for (var i = 0; i < argTypes.Length; i++) - { - var arg = Expression.Parameter(typeof(object)); - args[i] = arg; - argsConverted[i] = Expression.Convert(arg, argTypes[i]); - } - - Expression ctorExpr = Expression.New(ctor, argsConverted); // ctor takes args of specific types - - if (convertResultToObject) - ctorExpr = Expression.Convert(ctorExpr, typeof (object)); // convert ctor result to object - - return Expression.Lambda<T>(ctorExpr, args).Compile(); // lambda takes args as objects - } - - /// <summary> - /// Compiles the field setter. - /// </summary> - /// <param name="field">The field.</param> - /// <returns>Compiled field setter.</returns> - public static Action<object, object> CompileFieldSetter(FieldInfo field) - { - Debug.Assert(field != null); - Debug.Assert(field.DeclaringType != null); // non-static - - var targetParam = Expression.Parameter(typeof(object)); - var targetParamConverted = Expression.Convert(targetParam, field.DeclaringType); - - var valParam = Expression.Parameter(typeof(object)); - var valParamConverted = Expression.Convert(valParam, field.FieldType); - - var assignExpr = Expression.Call(GetWriteFieldMethod(field), targetParamConverted, valParamConverted); - - return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile(); - } - - /// <summary> - /// Compiles the property setter. - /// </summary> - /// <param name="prop">The property.</param> - /// <returns>Compiled property setter.</returns> - public static Action<object, object> CompilePropertySetter(PropertyInfo prop) - { - Debug.Assert(prop != null); - Debug.Assert(prop.DeclaringType != null); // non-static - - var targetParam = Expression.Parameter(typeof(object)); - var targetParamConverted = Expression.Convert(targetParam, prop.DeclaringType); - - var valParam = Expression.Parameter(typeof(object)); - var valParamConverted = Expression.Convert(valParam, prop.PropertyType); - - var fld = Expression.Property(targetParamConverted, prop); - - var assignExpr = Expression.Assign(fld, valParamConverted); - - return Expression.Lambda<Action<object, object>>(assignExpr, targetParam, valParam).Compile(); - } - - /// <summary> - /// Gets a method to write a field (including private and readonly). - /// NOTE: Expression Trees can't write readonly fields. - /// </summary> - /// <param name="field">The field.</param> - /// <returns>Resulting MethodInfo.</returns> - public static DynamicMethod GetWriteFieldMethod(FieldInfo field) - { - Debug.Assert(field != null); - - var module = Assembly.GetExecutingAssembly().GetModules()[0]; - - var method = new DynamicMethod(string.Empty, null, new[] { field.DeclaringType, field.FieldType }, module, - true); - - var il = method.GetILGenerator(); - - il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Ldarg_1); - il.Emit(OpCodes.Stfld, field); - il.Emit(OpCodes.Ret); - - return method; - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs deleted file mode 100644 index 8d7cb3a..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/DelegateTypeDescriptor.cs +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using Apache.Ignite.Core.Cache; - using Apache.Ignite.Core.Compute; - using Apache.Ignite.Core.Datastream; - using Apache.Ignite.Core.Events; - using Apache.Ignite.Core.Impl.Cache; - using Apache.Ignite.Core.Impl.Datastream; - using Apache.Ignite.Core.Impl.Portable.IO; - using Apache.Ignite.Core.Impl.Unmanaged; - using Apache.Ignite.Core.Messaging; - - /// <summary> - /// Type descriptor with precompiled delegates for known methods. - /// </summary> - internal class DelegateTypeDescriptor - { - /** Cached decriptors. */ - private static readonly CopyOnWriteConcurrentDictionary<Type, DelegateTypeDescriptor> Descriptors - = new CopyOnWriteConcurrentDictionary<Type, DelegateTypeDescriptor>(); - - /** */ - private readonly Func<object, object> _computeOutFunc; - - /** */ - private readonly Func<object, object, object> _computeFunc; - - /** */ - private readonly Func<object, Guid, object, bool> _eventFilter; - - /** */ - private readonly Func<object, object, object, bool> _cacheEntryFilter; - - /** */ - private readonly Tuple<Func<object, IMutableCacheEntryInternal, object, object>, Tuple<Type, Type>> - _cacheEntryProcessor; - - /** */ - private readonly Func<object, Guid, object, bool> _messageFilter; - - /** */ - private readonly Func<object, object> _computeJobExecute; - - /** */ - private readonly Action<object> _computeJobCancel; - - /** */ - private readonly Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> _streamReceiver; - - /** */ - private readonly Func<object, object> _streamTransformerCtor; - - /// <summary> - /// Gets the <see cref="IComputeFunc{T}" /> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, object> GetComputeOutFunc(Type type) - { - return Get(type)._computeOutFunc; - } - - /// <summary> - /// Gets the <see cref="IComputeFunc{T, R}" /> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, object, object> GetComputeFunc(Type type) - { - return Get(type)._computeFunc; - } - - /// <summary> - /// Gets the <see cref="IEventFilter{T}" /> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, Guid, object, bool> GetEventFilter(Type type) - { - return Get(type)._eventFilter; - } - - /// <summary> - /// Gets the <see cref="ICacheEntryFilter{TK,TV}" /> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, object, object, bool> GetCacheEntryFilter(Type type) - { - return Get(type)._cacheEntryFilter; - } - - /// <summary> - /// Gets the <see cref="ICacheEntryProcessor{K, V, A, R}" /> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, IMutableCacheEntryInternal, object, object> GetCacheEntryProcessor(Type type) - { - return Get(type)._cacheEntryProcessor.Item1; - } - - /// <summary> - /// Gets key and value types for the <see cref="ICacheEntryProcessor{K, V, A, R}" />. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Key and value types.</returns> - public static Tuple<Type, Type> GetCacheEntryProcessorTypes(Type type) - { - return Get(type)._cacheEntryProcessor.Item2; - } - - /// <summary> - /// Gets the <see cref="IMessageFilter{T}" /> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, Guid, object, bool> GetMessageFilter(Type type) - { - return Get(type)._messageFilter; - } - - /// <summary> - /// Gets the <see cref="IComputeJob{T}.Execute" /> and <see cref="IComputeJob{T}.Cancel" /> invocators. - /// </summary> - /// <param name="type">Type.</param> - /// <param name="execute">Execute invocator.</param> - /// <param name="cancel">Cancel invocator.</param> - public static void GetComputeJob(Type type, out Func<object, object> execute, out Action<object> cancel) - { - var desc = Get(type); - - execute = desc._computeJobExecute; - cancel = desc._computeJobCancel; - } - - /// <summary> - /// Gets the <see cref="IStreamReceiver{TK,TV}"/> invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool> GetStreamReceiver(Type type) - { - return Get(type)._streamReceiver; - } - - /// <summary> - /// Gets the <see cref="StreamTransformer{K, V, A, R}"/>> ctor invocator. - /// </summary> - /// <param name="type">Type.</param> - /// <returns>Precompiled invocator delegate.</returns> - public static Func<object, object> GetStreamTransformerCtor(Type type) - { - return Get(type)._streamTransformerCtor; - } - - /// <summary> - /// Gets the <see cref="DelegateTypeDescriptor" /> by type. - /// </summary> - private static DelegateTypeDescriptor Get(Type type) - { - DelegateTypeDescriptor result; - - return Descriptors.TryGetValue(type, out result) - ? result - : Descriptors.GetOrAdd(type, t => new DelegateTypeDescriptor(t)); - } - - /// <summary> - /// Throws an exception if first argument is not null. - /// </summary> - // ReSharper disable once UnusedParameter.Local - private static void ThrowIfMultipleInterfaces(object check, Type userType, Type interfaceType) - { - if (check != null) - throw new InvalidOperationException( - string.Format("Not Supported: Type {0} implements interface {1} multiple times.", userType, - interfaceType)); - } - - /// <summary> - /// Initializes a new instance of the <see cref="DelegateTypeDescriptor"/> class. - /// </summary> - /// <param name="type">The type.</param> - private DelegateTypeDescriptor(Type type) - { - foreach (var iface in type.GetInterfaces()) - { - if (!iface.IsGenericType) - continue; - - var genericTypeDefinition = iface.GetGenericTypeDefinition(); - - if (genericTypeDefinition == typeof (IComputeFunc<>)) - { - ThrowIfMultipleInterfaces(_computeOutFunc, type, typeof(IComputeFunc<>)); - - _computeOutFunc = DelegateConverter.CompileFunc(iface); - } - else if (genericTypeDefinition == typeof (IComputeFunc<,>)) - { - ThrowIfMultipleInterfaces(_computeFunc, type, typeof(IComputeFunc<,>)); - - var args = iface.GetGenericArguments(); - - _computeFunc = DelegateConverter.CompileFunc<Func<object, object, object>>(iface, new[] {args[0]}); - } - else if (genericTypeDefinition == typeof (IEventFilter<>)) - { - ThrowIfMultipleInterfaces(_eventFilter, type, typeof(IEventFilter<>)); - - var args = iface.GetGenericArguments(); - - _eventFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface, - new[] {typeof (Guid), args[0]}, new[] {false, true, false}); - } - else if (genericTypeDefinition == typeof (ICacheEntryFilter<,>)) - { - ThrowIfMultipleInterfaces(_cacheEntryFilter, type, typeof(ICacheEntryFilter<,>)); - - var args = iface.GetGenericArguments(); - - var entryType = typeof (ICacheEntry<,>).MakeGenericType(args); - - var invokeFunc = DelegateConverter.CompileFunc<Func<object, object, bool>>(iface, - new[] { entryType }, new[] { true, false }); - - var ctor = DelegateConverter.CompileCtor<Func<object, object, object>>( - typeof (CacheEntry<,>).MakeGenericType(args), args); - - // Resulting func constructs CacheEntry and passes it to user implementation - _cacheEntryFilter = (obj, k, v) => invokeFunc(obj, ctor(k, v)); - } - else if (genericTypeDefinition == typeof (ICacheEntryProcessor<,,,>)) - { - ThrowIfMultipleInterfaces(_cacheEntryProcessor, type, typeof(ICacheEntryProcessor<,,,>)); - - var args = iface.GetGenericArguments(); - - var entryType = typeof (IMutableCacheEntry<,>).MakeGenericType(args[0], args[1]); - - var func = DelegateConverter.CompileFunc<Func<object, object, object, object>>(iface, - new[] { entryType, args[2] }, null, "Process"); - - var types = new Tuple<Type, Type>(args[0], args[1]); - - _cacheEntryProcessor = new Tuple<Func<object, IMutableCacheEntryInternal, object, object>, Tuple<Type, Type>> - (func, types); - - var transformerType = typeof (StreamTransformer<,,,>).MakeGenericType(args); - - _streamTransformerCtor = DelegateConverter.CompileCtor<Func<object, object>>(transformerType, - new[] {iface}); - } - else if (genericTypeDefinition == typeof (IMessageFilter<>)) - { - ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IMessageFilter<>)); - - var arg = iface.GetGenericArguments()[0]; - - _messageFilter = DelegateConverter.CompileFunc<Func<object, Guid, object, bool>>(iface, - new[] { typeof(Guid), arg }, new[] { false, true, false }); - } - else if (genericTypeDefinition == typeof (IComputeJob<>)) - { - ThrowIfMultipleInterfaces(_messageFilter, type, typeof(IComputeJob<>)); - - _computeJobExecute = DelegateConverter.CompileFunc<Func<object, object>>(iface, new Type[0], - methodName: "Execute"); - - _computeJobCancel = DelegateConverter.CompileFunc<Action<object>>(iface, new Type[0], - new[] {false}, "Cancel"); - } - else if (genericTypeDefinition == typeof (IStreamReceiver<,>)) - { - ThrowIfMultipleInterfaces(_streamReceiver, type, typeof (IStreamReceiver<,>)); - - var method = - typeof (StreamReceiverHolder).GetMethod("InvokeReceiver") - .MakeGenericMethod(iface.GetGenericArguments()); - - _streamReceiver = DelegateConverter - .CompileFunc<Action<object, Ignite, IUnmanagedTarget, IPortableStream, bool>>( - typeof (StreamReceiverHolder), - method, - new[] - { - iface, typeof (Ignite), typeof (IUnmanagedTarget), typeof (IPortableStream), - typeof (bool) - }, - new[] {true, false, false, false, false, false}); - } - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs deleted file mode 100644 index 92b4fce..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Threading; - using System.Threading.Tasks; - using Apache.Ignite.Core.Common; - using Apache.Ignite.Core.Impl.Portable.IO; - - /// <summary> - /// Grid future implementation. - /// </summary> - [SuppressMessage("ReSharper", "ParameterHidesMember")] - [CLSCompliant(false)] - public sealed class Future<T> : IFutureInternal, IFuture<T> - { - /** Converter. */ - private readonly IFutureConverter<T> _converter; - - /** Result. */ - private T _res; - - /** Caught cxception. */ - private Exception _err; - - /** Done flag. */ - private volatile bool _done; - - /** Listener(s). Either Action or List{Action}. */ - private object _callbacks; - - /// <summary> - /// Constructor. - /// </summary> - /// <param name="converter">Future result marshaller and converter.</param> - public Future(IFutureConverter<T> converter = null) - { - _converter = converter; - } - - /** <inheritdoc/> */ - public bool IsDone - { - get { return _done; } - } - - /** <inheritdoc/> */ - public T Get() - { - if (!_done) - { - lock (this) - { - while (!_done) - Monitor.Wait(this); - } - } - - return Get0(); - } - - /** <inheritdoc/> */ - public T Get(TimeSpan timeout) - { - long ticks = timeout.Ticks; - - if (ticks < 0) - throw new ArgumentException("Timeout cannot be negative."); - - if (ticks == 0) - return Get(); - - if (!_done) - { - // Fallback to locked mode. - lock (this) - { - long endTime = DateTime.Now.Ticks + ticks; - - if (!_done) - { - while (true) - { - Monitor.Wait(this, timeout); - - if (_done) - break; - - ticks = endTime - DateTime.Now.Ticks; - - if (ticks <= 0) - throw new TimeoutException("Timeout waiting for future completion."); - - timeout = TimeSpan.FromTicks(ticks); - } - } - } - } - - return Get0(); - } - - /** <inheritdoc/> */ - public void Listen(Action callback) - { - Listen((Action<IFuture<T>>) (fut => callback())); - } - - /** <inheritdoc/> */ - public void Listen(Action<IFuture> callback) - { - Listen((Action<IFuture<T>>)callback); - } - - /** <inheritdoc/> */ - public void Listen(Action<IFuture<T>> callback) - { - IgniteArgumentCheck.NotNull(callback, "callback"); - - if (!_done) - { - lock (this) - { - if (!_done) - { - AddCallback(callback); - - return; - } - } - } - - callback(this); - } - - /// <summary> - /// Get result or throw an error. - /// </summary> - private T Get0() - { - if (_err != null) - throw _err; - - return _res; - } - - /** <inheritdoc/> */ - public IAsyncResult ToAsyncResult() - { - return _done ? CompletedAsyncResult.Instance : new AsyncResult(this); - } - - /** <inheritdoc/> */ - Task<object> IFuture.ToTask() - { - return Task.Factory.FromAsync(ToAsyncResult(), x => (object) Get()); - } - - /** <inheritdoc/> */ - public Task<T> ToTask() - { - return Task.Factory.FromAsync(ToAsyncResult(), x => Get()); - } - - /** <inheritdoc/> */ - object IFuture.Get(TimeSpan timeout) - { - return Get(timeout); - } - - /** <inheritdoc/> */ - object IFuture.Get() - { - return Get(); - } - - /** <inheritdoc /> */ - public void OnResult(IPortableStream stream) - { - try - { - OnResult(_converter.Convert(stream)); - } - catch (Exception ex) - { - OnError(ex); - } - } - - /** <inheritdoc /> */ - public void OnError(Exception err) - { - OnDone(default(T), err); - } - - /** <inheritdoc /> */ - public void OnNullResult() - { - OnResult(default(T)); - } - - /// <summary> - /// Set result. - /// </summary> - /// <param name="res">Result.</param> - internal void OnResult(T res) - { - OnDone(res, null); - } - - /// <summary> - /// Set future to Done state. - /// </summary> - /// <param name="res">Result.</param> - /// <param name="err">Error.</param> - public void OnDone(T res, Exception err) - { - object callbacks0 = null; - - lock (this) - { - if (!_done) - { - _res = res; - _err = err; - - _done = true; - - Monitor.PulseAll(this); - - // Notify listeners outside the lock - callbacks0 = _callbacks; - _callbacks = null; - } - } - - if (callbacks0 != null) - { - var list = callbacks0 as List<Action<IFuture<T>>>; - - if (list != null) - list.ForEach(x => x(this)); - else - ((Action<IFuture<T>>) callbacks0)(this); - } - } - - /// <summary> - /// Adds a callback. - /// </summary> - private void AddCallback(Action<IFuture<T>> callback) - { - if (_callbacks == null) - { - _callbacks = callback; - - return; - } - - var list = _callbacks as List<Action<IFuture<T>>> ?? - new List<Action<IFuture<T>>> {(Action<IFuture<T>>) _callbacks}; - - list.Add(callback); - - _callbacks = list; - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs deleted file mode 100644 index a07d954..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureConverter.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using Apache.Ignite.Core.Impl.Portable; - using Apache.Ignite.Core.Impl.Portable.IO; - - /// <summary> - /// Marshals and converts future value. - /// </summary> - internal class FutureConverter<T> : IFutureConverter<T> - { - /** Marshaller. */ - private readonly PortableMarshaller _marsh; - - /** Keep portable flag. */ - private readonly bool _keepPortable; - - /** Converting function. */ - private readonly Func<PortableReaderImpl, T> _func; - - /// <summary> - /// Constructor. - /// </summary> - /// <param name="marsh">Marshaller.</param> - /// <param name="keepPortable">Keep portable.</param> - /// <param name="func">Converting function.</param> - public FutureConverter(PortableMarshaller marsh, bool keepPortable, - Func<PortableReaderImpl, T> func = null) - { - _marsh = marsh; - _keepPortable = keepPortable; - _func = func ?? (reader => reader.ReadObject<T>()); - } - - /// <summary> - /// Read and convert a value. - /// </summary> - public T Convert(IPortableStream stream) - { - var reader = _marsh.StartUnmarshal(stream, _keepPortable); - - return _func(reader); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs deleted file mode 100644 index 0beff04..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - /// <summary> - /// Future types. - /// </summary> - public enum FutureType - { - /** Future type: byte. */ - Byte = 1, - - /** Future type: boolean. */ - Bool = 2, - - /** Future type: short. */ - Short = 3, - - /** Future type: char. */ - Char = 4, - - /** Future type: int. */ - Int = 5, - - /** Future type: float. */ - Float = 6, - - /** Future type: long. */ - Long = 7, - - /** Future type: double. */ - Double = 8, - - /** Future type: object. */ - Object = 9 - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs deleted file mode 100644 index e07597d..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using Apache.Ignite.Core.Impl.Portable.IO; - - /// <summary> - /// Marshals and converts future value. - /// </summary> - [CLSCompliant(false)] - public interface IFutureConverter<out T> - { - /// <summary> - /// Reads and converts a value. - /// </summary> - T Convert(IPortableStream stream); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs deleted file mode 100644 index 90f06be..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IFutureInternal.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using Apache.Ignite.Core.Impl.Portable.IO; - - /// <summary> - /// Internal future interface. - /// </summary> - [CLSCompliant(false)] - public interface IFutureInternal - { - /// <summary> - /// Set result from stream. - /// </summary> - /// <param name="stream">Stream.</param> - void OnResult(IPortableStream stream); - - /// <summary> - /// Set null result. - /// </summary> - void OnNullResult(); - - /// <summary> - /// Set error result. - /// </summary> - /// <param name="err">Exception.</param> - void OnError(Exception err); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs deleted file mode 100644 index e94c577..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/IgniteArgumentCheck.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Collections.Generic; - - /// <summary> - /// Arguments check helpers. - /// </summary> - public static class IgniteArgumentCheck - { - /// <summary> - /// Throws an ArgumentNullException if specified arg is null. - /// </summary> - /// <param name="arg">The argument.</param> - /// <param name="argName">Name of the argument.</param> - public static void NotNull(object arg, string argName) - { - if (arg == null) - throw new ArgumentNullException(argName); - } - - /// <summary> - /// Throws an ArgumentException if specified arg is null or empty string. - /// </summary> - /// <param name="arg">The argument.</param> - /// <param name="argName">Name of the argument.</param> - public static void NotNullOrEmpty(string arg, string argName) - { - if (string.IsNullOrEmpty(arg)) - throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName), - argName); - } - - /// <summary> - /// Throws an ArgumentException if specified arg is null or empty string. - /// </summary> - /// <param name="collection">The collection.</param> - /// <param name="argName">Name of the argument.</param> - public static void NotNullOrEmpty<T>(ICollection<T> collection, string argName) - { - if (collection == null || collection.Count == 0) - throw new ArgumentException(string.Format("'{0}' argument should not be null or empty.", argName), - argName); - } - - /// <summary> - /// Throws an ArgumentException if specified condition is false. - /// </summary> - /// <param name="condition">Condition.</param> - /// <param name="argName">Name of the argument.</param> - /// <param name="message">Message.</param> - public static void Ensure(bool condition, string argName, string message) - { - if (!condition) - throw new ArgumentException(string.Format("'{0}' argument is invalid: {1}", argName, message), - argName); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs deleted file mode 100644 index c158d5c..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/LoadedAssembliesResolver.cs +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - using System.Reflection; - - /// <summary> - /// Resolves loaded assemblies by name. - /// </summary> - public class LoadedAssembliesResolver - { - // The lazy singleton instance. - private static readonly Lazy<LoadedAssembliesResolver> LazyInstance = new Lazy<LoadedAssembliesResolver>(); - - // Assemblies map. - private volatile Dictionary<string, Assembly> _map; - - /// <summary> - /// Initializes a new instance of the <see cref="LoadedAssembliesResolver"/> class. - /// </summary> - public LoadedAssembliesResolver() - { - lock (this) - { - AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad; - - UpdateMap(); - } - } - - /// <summary> - /// Handles the AssemblyLoad event of the AppDomain. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="args">The <see cref="AssemblyLoadEventArgs"/> instance containing the event data.</param> - private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args) - { - lock (this) - { - UpdateMap(); - } - } - - /// <summary> - /// Updates the assembly map according to the current list of loaded assemblies. - /// </summary> - private void UpdateMap() - { - var assemblies = AppDomain.CurrentDomain.GetAssemblies(); - - _map = new Dictionary<string, Assembly>(assemblies.Length); - - foreach (var assembly in assemblies) - _map[assembly.FullName] = assembly; - } - - /// <summary> - /// Gets the singleton instance. - /// </summary> - public static LoadedAssembliesResolver Instance - { - get { return LazyInstance.Value; } - } - - /// <summary> - /// Gets the assembly by name. - /// </summary> - /// <param name="assemblyName">Name of the assembly.</param> - /// <returns>Assembly with specified name, or null.</returns> - [SuppressMessage("ReSharper", "InconsistentlySynchronizedField")] - public Assembly GetAssembly(string assemblyName) - { - Assembly asm; - - return _map.TryGetValue(assemblyName, out asm) ? asm : null; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs deleted file mode 100644 index 733bed0..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using Apache.Ignite.Core.Impl.Portable; - using Apache.Ignite.Core.Portable; - - /// <summary> - /// Simple wrapper over result to handle marshalling properly. - /// </summary> - internal class PortableResultWrapper : IPortableWriteAware - { - /** */ - private readonly object _result; - - /// <summary> - /// Initializes a new instance of the <see cref="PortableResultWrapper"/> class. - /// </summary> - /// <param name="reader">The reader.</param> - public PortableResultWrapper(IPortableReader reader) - { - var reader0 = (PortableReaderImpl)reader.RawReader(); - - _result = PortableUtils.ReadPortableOrSerializable<object>(reader0); - } - - /// <summary> - /// Constructor. - /// </summary> - /// <param name="res">Result.</param> - public PortableResultWrapper(object res) - { - _result = res; - } - - /// <summary> - /// Result. - /// </summary> - public object Result - { - get { return _result; } - } - - /** <inheritDoc /> */ - public void WritePortable(IPortableWriter writer) - { - var writer0 = (PortableWriterImpl) writer.RawWriter(); - - writer0.DetachNext(); - PortableUtils.WritePortableOrSerializable(writer0, Result); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs deleted file mode 100644 index d0dd2a9..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Common/TypeCaster.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Common -{ - using System; - using System.Linq.Expressions; - - /// <summary> - /// Does type casts without extra boxing. - /// Should be used when casting compile-time incompatible value types instead of "(T)(object)x". - /// </summary> - /// <typeparam name="T">Target type</typeparam> - public static class TypeCaster<T> - { - /// <summary> - /// Efficiently casts an object from TFrom to T. - /// Does not cause boxing for value types. - /// </summary> - /// <typeparam name="TFrom">Source type to cast from.</typeparam> - /// <param name="obj">The object to cast.</param> - /// <returns>Casted object.</returns> - public static T Cast<TFrom>(TFrom obj) - { - return Casters<TFrom>.Caster(obj); - } - - /// <summary> - /// Inner class serving as a cache. - /// </summary> - private static class Casters<TFrom> - { - /// <summary> - /// Compiled caster delegate. - /// </summary> - internal static readonly Func<TFrom, T> Caster = Compile(); - - /// <summary> - /// Compiles caster delegate. - /// </summary> - private static Func<TFrom, T> Compile() - { - if (typeof (T) == typeof (TFrom)) - { - // Just return what we have - var pExpr = Expression.Parameter(typeof(TFrom)); - - return Expression.Lambda<Func<TFrom, T>>(pExpr, pExpr).Compile(); - } - - var paramExpr = Expression.Parameter(typeof(TFrom)); - var convertExpr = Expression.Convert(paramExpr, typeof(T)); - - return Expression.Lambda<Func<TFrom, T>>(convertExpr, paramExpr).Compile(); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs deleted file mode 100644 index 1a772c2..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Compute.Closure -{ - using System; - using System.Collections.Generic; - using Apache.Ignite.Core.Cluster; - using Apache.Ignite.Core.Compute; - - /// <summary> - /// Base class for all tasks working with closures. - /// </summary> - internal abstract class ComputeAbstractClosureTask<TA, T, TR> : IComputeTask<TA, T, TR> - { - /// <summary> - /// This method is called to map or split Ignite task into multiple Ignite jobs. This is the - /// first method that gets called when task execution starts. - /// </summary> - /// <param name="subgrid">Nodes available for this task execution. Note that order of nodes is - /// guaranteed to be randomized by container. This ensures that every time you simply iterate - /// through Ignite nodes, the order of nodes will be random which over time should result into - /// all nodes being used equally.</param> - /// <param name="arg">Task execution argument. Can be <c>null</c>. This is the same argument - /// as the one passed into <c>ICompute.Execute()</c> methods.</param> - /// <returns> - /// Map of Ignite jobs assigned to subgrid node. If <c>null</c> or empty map is returned, - /// exception will be thrown. - /// </returns> - /// <exception cref="System.NotSupportedException">Map step should not be called on this task.</exception> - public IDictionary<IComputeJob<T>, IClusterNode> Map(IList<IClusterNode> subgrid, TA arg) - { - throw new NotSupportedException("Map step should not be called on this task."); - } - - /// <summary> - /// Asynchronous callback invoked every time a result from remote execution is - /// received. It is ultimately upto this method to return a policy based - /// on which the system will either wait for more results, reduce results - /// received so far, or failover this job to another node. See - /// <see cref="ComputeJobResultPolicy" /> for more information. - /// </summary> - /// <param name="res">Received remote Ignite executable result.</param> - /// <param name="rcvd">All previously received results. Note that if task class has - /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param> - /// <returns> - /// Result policy that dictates how to process further upcoming job results. - /// </returns> - public ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd) - { - Exception err = res.Exception(); - - if (err != null) - { - if (err is ComputeExecutionRejectedException || err is ClusterTopologyException || - err is ComputeJobFailoverException) - return ComputeJobResultPolicy.Failover; - - throw err; - } - - return Result0(res); - } - - /// <summary> - /// Reduces (or aggregates) results received so far into one compound result to be returned to - /// caller via future. - /// <para /> - /// Note, that if some jobs did not succeed and could not be failed over then the list of - /// results passed into this method will include the failed results. Otherwise, failed - /// results will not be in the list. - /// </summary> - /// <param name="results">Received job results. Note that if task class has - /// <see cref="ComputeTaskNoResultCacheAttribute" /> attribute, then this list will be empty.</param> - /// <returns> - /// Task result constructed from results of remote executions. - /// </returns> - public abstract TR Reduce(IList<IComputeJobResult<T>> results); - - /// <summary> - /// Internal result processing routine. - /// </summary> - /// <param name="res">Result.</param> - /// <returns>Policy.</returns> - protected abstract ComputeJobResultPolicy Result0(IComputeJobResult<T> res); - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs deleted file mode 100644 index c91a167..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Compute.Closure -{ - using System; - using Apache.Ignite.Core.Compute; - using Apache.Ignite.Core.Impl.Portable; - using Apache.Ignite.Core.Impl.Resource; - using Apache.Ignite.Core.Portable; - - /// <summary> - /// System job which wraps over <c>Action</c>. - /// </summary> - internal class ComputeActionJob : IComputeJob, IComputeResourceInjector, IPortableWriteAware - { - /** Closure. */ - private readonly IComputeAction _action; - - /// <summary> - /// Constructor. - /// </summary> - /// <param name="action">Action.</param> - public ComputeActionJob(IComputeAction action) - { - _action = action; - } - - /** <inheritDoc /> */ - public object Execute() - { - _action.Invoke(); - - return null; - } - - /** <inheritDoc /> */ - public void Cancel() - { - throw new NotSupportedException("Func job cannot be cancelled."); - } - - /** <inheritDoc /> */ - public void Inject(Ignite grid) - { - ResourceProcessor.Inject(_action, grid); - } - - /** <inheritDoc /> */ - public void WritePortable(IPortableWriter writer) - { - var writer0 = (PortableWriterImpl)writer.RawWriter(); - - writer0.DetachNext(); - PortableUtils.WritePortableOrSerializable(writer0, _action); - } - - /// <summary> - /// Initializes a new instance of the <see cref="ComputeActionJob"/> class. - /// </summary> - /// <param name="reader">The reader.</param> - public ComputeActionJob(IPortableReader reader) - { - var reader0 = (PortableReaderImpl)reader.RawReader(); - - _action = PortableUtils.ReadPortableOrSerializable<IComputeAction>(reader0); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs deleted file mode 100644 index 381c701..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Compute.Closure -{ - using System; - using Apache.Ignite.Core.Impl.Portable; - using Apache.Ignite.Core.Impl.Resource; - using Apache.Ignite.Core.Portable; - - /// <summary> - /// System job which wraps over <c>Func</c>. - /// </summary> - internal class ComputeFuncJob : IComputeJob, IComputeResourceInjector, IPortableWriteAware - { - /** Closure. */ - private readonly IComputeFunc _clo; - - /** Argument. */ - private readonly object _arg; - - /// <summary> - /// Constructor. - /// </summary> - /// <param name="clo">Closure.</param> - /// <param name="arg">Argument.</param> - public ComputeFuncJob(IComputeFunc clo, object arg) - { - _clo = clo; - _arg = arg; - } - - /** <inheritDoc /> */ - public object Execute() - { - return _clo.Invoke(_arg); - } - - /** <inheritDoc /> */ - public void Cancel() - { - throw new NotSupportedException("Func job cannot be cancelled."); - } - - /** <inheritDoc /> */ - public void Inject(Ignite grid) - { - ResourceProcessor.Inject(_clo, grid); - } - - /** <inheritDoc /> */ - public void WritePortable(IPortableWriter writer) - { - PortableWriterImpl writer0 = (PortableWriterImpl) writer.RawWriter(); - - writer0.DetachNext(); - PortableUtils.WritePortableOrSerializable(writer0, _clo); - - writer0.DetachNext(); - PortableUtils.WritePortableOrSerializable(writer0, _arg); - } - - /// <summary> - /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class. - /// </summary> - /// <param name="reader">The reader.</param> - public ComputeFuncJob(IPortableReader reader) - { - var reader0 = (PortableReaderImpl) reader.RawReader(); - - _clo = PortableUtils.ReadPortableOrSerializable<IComputeFunc>(reader0); - _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0); - } - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/f0bac562/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs ---------------------------------------------------------------------- diff --git a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs b/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs deleted file mode 100644 index dd57f6c..0000000 --- a/modules/platform/src/main/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace Apache.Ignite.Core.Impl.Compute.Closure -{ - using System.Collections.Generic; - using Apache.Ignite.Core.Compute; - - /// <summary> - /// Closure-based task producing multiple jobs and returning a collection of job results. - /// </summary> - [ComputeTaskNoResultCache] - internal class ComputeMultiClosureTask<TA, T, TR> : ComputeAbstractClosureTask<TA, T, TR> - where TR : ICollection<T> - { - /** Result. */ - private readonly ICollection<T> _res; - - /// <summary> - /// Constructor. - /// </summary> - /// <param name="size">Expected results count.</param> - public ComputeMultiClosureTask(int size) - { - _res = new List<T>(size); - } - - /** <inheritDoc /> */ - protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res) - { - _res.Add(res.Data()); - - return ComputeJobResultPolicy.Wait; - } - - /** <inheritDoc /> */ - public override TR Reduce(IList<IComputeJobResult<T>> results) - { - return (TR) _res; - } - } -}
