Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1822B200CEB for ; Fri, 28 Jul 2017 14:07:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 169B916C8BD; Fri, 28 Jul 2017 12:07:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D3C3616CAA9 for ; Fri, 28 Jul 2017 14:07:16 +0200 (CEST) Received: (qmail 34769 invoked by uid 500); 28 Jul 2017 12:07:16 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 34580 invoked by uid 99); 28 Jul 2017 12:07:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jul 2017 12:07:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0EBAAF3314; Fri, 28 Jul 2017 12:07:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yzhdanov@apache.org To: commits@ignite.apache.org Date: Fri, 28 Jul 2017 12:07:56 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [44/50] [abbrv] ignite git commit: IGNITE-5769 Abstract away .NET->Java calls archived-at: Fri, 28 Jul 2017 12:07:20 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs new file mode 100644 index 0000000..64b5f29 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTargetAdapter.cs @@ -0,0 +1,534 @@ +/* + * 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 +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; + using System.Threading.Tasks; + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Impl.Binary; + using Apache.Ignite.Core.Impl.Binary.IO; + using Apache.Ignite.Core.Impl.Common; + using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader; + using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter; + + /// + /// Base class for interop targets, provides additional functionality over . + /// + [SuppressMessage("ReSharper", "LocalVariableHidesMember")] + internal class PlatformTargetAdapter + { + /** */ + internal const int False = 0; + + /** */ + internal const int True = 1; + + /** */ + internal const int Error = -1; + + /** */ + private static readonly Dictionary IgniteFutureTypeMap + = new Dictionary + { + {typeof(bool), FutureType.Bool}, + {typeof(byte), FutureType.Byte}, + {typeof(char), FutureType.Char}, + {typeof(double), FutureType.Double}, + {typeof(float), FutureType.Float}, + {typeof(int), FutureType.Int}, + {typeof(long), FutureType.Long}, + {typeof(short), FutureType.Short} + }; + + /** Unmanaged target. */ + private readonly IPlatformTargetInternal _target; + + /** Marshaller. */ + private readonly Marshaller _marsh; + + /// + /// Constructor. + /// + /// Target. + protected PlatformTargetAdapter(IPlatformTargetInternal target) + { + Debug.Assert(target != null); + + _target = target; + _marsh = target.Marshaller; + } + + /// + /// Unmanaged target. + /// + internal IPlatformTargetInternal Target + { + get { return _target; } + } + + /// + /// Marshaller. + /// + internal Marshaller Marshaller + { + get { return _marsh; } + } + + #region OUT operations + + /// + /// Perform out operation. + /// + /// Operation type. + /// Action to be performed on the stream. + /// + protected long DoOutOp(int type, Action action) + { + return _target.InStreamOutLong(type, action); + } + + /// + /// Perform out operation. + /// + /// Operation type. + /// Action to be performed on the stream. + /// + protected long DoOutOp(int type, Action action) + { + return DoOutOp(type, stream => WriteToStream(action, stream, _marsh)); + } + + /// + /// Perform out operation. + /// + /// Operation type. + /// Action to be performed on the stream. + /// Resulting object. + protected IPlatformTargetInternal DoOutOpObject(int type, Action action) + { + return _target.InStreamOutObject(type, stream => WriteToStream(action, stream, _marsh)); + } + + /// + /// Perform out operation. + /// + /// Operation type. + /// Action to be performed on the stream. + /// Resulting object. + protected IPlatformTargetInternal DoOutOpObject(int type, Action action) + { + return _target.InStreamOutObject(type, action); + } + + /// + /// Perform out operation. + /// + /// Operation type. + /// Resulting object. + protected IPlatformTargetInternal DoOutOpObject(int type) + { + return _target.OutObjectInternal(type); + } + + /// + /// Perform simple output operation accepting single argument. + /// + /// Operation type. + /// Value. + /// Result. + protected long DoOutOp(int type, T1 val1) + { + return DoOutOp(type, writer => + { + writer.Write(val1); + }); + } + + /// + /// Perform simple output operation accepting two arguments. + /// + /// Operation type. + /// Value 1. + /// Value 2. + /// Result. + protected long DoOutOp(int type, T1 val1, T2 val2) + { + return DoOutOp(type, writer => + { + writer.Write(val1); + writer.Write(val2); + }); + } + + #endregion + + #region IN operations + + /// + /// Perform in operation. + /// + /// Type. + /// Action. + /// Result. + protected T DoInOp(int type, Func action) + { + return _target.OutStream(type, action); + } + + /// + /// Perform simple in operation returning immediate result. + /// + /// Type. + /// Result. + protected T DoInOp(int type) + { + return _target.OutStream(type, s => Unmarshal(s)); + } + + #endregion + + #region OUT-IN operations + + /// + /// Perform out-in operation. + /// + /// Operation type. + /// Out action. + /// In action. + /// Result. + protected TR DoOutInOp(int type, Action outAction, Func inAction) + { + return _target.InStreamOutStream(type, stream => WriteToStream(outAction, stream, _marsh), inAction); + } + + /// + /// Perform out-in operation with a single stream. + /// + /// The type of the r. + /// Operation type. + /// Out action. + /// In action. + /// The action to read an error. + /// + /// Result. + /// + protected TR DoOutInOpX(int type, Action outAction, Func inAction, + Func inErrorAction) + { + return _target.InStreamOutLong(type, stream => WriteToStream(outAction, stream, _marsh), + inAction, inErrorAction); + } + + /// + /// Perform out-in operation with a single stream. + /// + /// Operation type. + /// Out action. + /// The action to read an error. + /// + /// Result. + /// + protected bool DoOutInOpX(int type, Action outAction, + Func inErrorAction) + { + return _target.InStreamOutLong(type, stream => WriteToStream(outAction, stream, _marsh), + (stream, res) => res == True, inErrorAction); + } + + /// + /// Perform out-in operation. + /// + /// Operation type. + /// Out action. + /// In action. + /// Argument. + /// Result. + protected TR DoOutInOp(int type, Action outAction, + Func inAction, IPlatformTargetInternal arg) + { + return _target.InObjectStreamOutObjectStream(type, stream => WriteToStream(outAction, stream, _marsh), + inAction, arg); + } + + /// + /// Perform out-in operation. + /// + /// Operation type. + /// Out action. + /// Result. + protected TR DoOutInOp(int type, Action outAction) + { + return _target.InStreamOutStream(type, stream => WriteToStream(outAction, stream, _marsh), + stream => Unmarshal(stream)); + } + + /// + /// Perform simple out-in operation accepting single argument. + /// + /// Operation type. + /// Value. + /// Result. + protected TR DoOutInOp(int type, T1 val) + { + return _target.InStreamOutStream(type, stream => WriteToStream(val, stream, _marsh), + stream => Unmarshal(stream)); + } + + /// + /// Perform simple out-in operation accepting two arguments. + /// + /// Operation type. + /// Value. + /// Result. + protected long DoOutInOp(int type, long val = 0) + { + return _target.InLongOutLong(type, val); + } + + #endregion + + #region Async operations + + /// + /// Performs async operation. + /// + /// The type code. + /// The write action. + /// Task for async operation + protected Task DoOutOpAsync(int type, Action writeAction = null) + { + return DoOutOpAsync(type, writeAction); + } + + /// + /// Performs async operation. + /// + /// Type of the result. + /// The type code. + /// The write action. + /// Keep binary flag, only applicable to object futures. False by default. + /// The function to read future result from stream. + /// Task for async operation + protected Task DoOutOpAsync(int type, Action writeAction = null, bool keepBinary = false, + Func convertFunc = null) + { + return GetFuture((futId, futType) => DoOutOp(type, w => + { + if (writeAction != null) + { + writeAction(w); + } + w.WriteLong(futId); + w.WriteInt(futType); + }), keepBinary, convertFunc).Task; + } + + /// + /// Performs async operation. + /// + /// Type of the result. + /// The type code. + /// The write action. + /// Future for async operation + protected Future DoOutOpObjectAsync(int type, Action writeAction) + { + return GetFuture((futId, futType) => DoOutOpObject(type, w => + { + writeAction(w); + w.WriteLong(futId); + w.WriteInt(futType); + })); + } + + /// + /// Performs async operation. + /// + /// Type of the result. + /// The type of the first arg. + /// The type code. + /// First arg. + /// + /// Task for async operation + /// + protected Task DoOutOpAsync(int type, T1 val1) + { + return GetFuture((futId, futType) => DoOutOp(type, w => + { + w.WriteObject(val1); + w.WriteLong(futId); + w.WriteInt(futType); + })).Task; + } + + /// + /// Performs async operation. + /// + /// Type of the result. + /// The type of the first arg. + /// The type of the second arg. + /// The type code. + /// First arg. + /// Second arg. + /// + /// Task for async operation + /// + protected Task DoOutOpAsync(int type, T1 val1, T2 val2) + { + return GetFuture((futId, futType) => DoOutOp(type, w => + { + w.WriteObject(val1); + w.WriteObject(val2); + w.WriteLong(futId); + w.WriteInt(futType); + })).Task; + } + + #endregion + + #region Miscelanneous + + /// + /// Finish marshaling. + /// + /// Writer. + internal void FinishMarshal(BinaryWriter writer) + { + _marsh.FinishMarshal(writer); + } + + /// + /// Unmarshal object using the given stream. + /// + /// Stream. + /// Unmarshalled object. + protected virtual T Unmarshal(IBinaryStream stream) + { + return _marsh.Unmarshal(stream); + } + + /// + /// Creates a future and starts listening. + /// + /// Future result type + /// The listen action. + /// Keep binary flag, only applicable to object futures. False by default. + /// The function to read future result from stream. + /// Created future. + private Future GetFuture(Func listenAction, bool keepBinary = false, + Func convertFunc = null) + { + var futType = FutureType.Object; + + var type = typeof(T); + + if (type.IsPrimitive) + IgniteFutureTypeMap.TryGetValue(type, out futType); + + var fut = convertFunc == null && futType != FutureType.Object + ? new Future() + : new Future(new FutureConverter(_marsh, keepBinary, convertFunc)); + + var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut); + + IPlatformTargetInternal futTarget; + + try + { + futTarget = listenAction(futHnd, (int)futType); + } + catch (Exception) + { + _marsh.Ignite.HandleRegistry.Release(futHnd); + + throw; + } + + fut.SetTarget(new Listenable(futTarget)); + + return fut; + } + + /// + /// Creates a future and starts listening. + /// + /// Future result type + /// The listen action. + /// Keep binary flag, only applicable to object futures. False by default. + /// The function to read future result from stream. + /// Created future. + private Future GetFuture(Action listenAction, bool keepBinary = false, + Func convertFunc = null) + { + var futType = FutureType.Object; + + var type = typeof(T); + + if (type.IsPrimitive) + IgniteFutureTypeMap.TryGetValue(type, out futType); + + var fut = convertFunc == null && futType != FutureType.Object + ? new Future() + : new Future(new FutureConverter(_marsh, keepBinary, convertFunc)); + + var futHnd = _marsh.Ignite.HandleRegistry.Allocate(fut); + + try + { + listenAction(futHnd, (int)futType); + } + catch (Exception) + { + _marsh.Ignite.HandleRegistry.Release(futHnd); + + throw; + } + + return fut; + } + + /// + /// Writes to stream. + /// + private static void WriteToStream(Action action, IBinaryStream stream, Marshaller marsh) + { + var writer = marsh.StartMarshal(stream); + + action(writer); + + marsh.FinishMarshal(writer); + } + + /// + /// Writes to stream. + /// + private static void WriteToStream(T obj, IBinaryStream stream, Marshaller marsh) + { + var writer = marsh.StartMarshal(stream); + + writer.WriteObject(obj); + + marsh.FinishMarshal(writer); + } + + + #endregion + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs index 88d2a76..93611f7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs @@ -24,16 +24,13 @@ namespace Apache.Ignite.Core.Impl.Services using System.Threading.Tasks; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cluster; - using Apache.Ignite.Core.Impl.Binary; using Apache.Ignite.Core.Impl.Common; - using Apache.Ignite.Core.Impl.Unmanaged; using Apache.Ignite.Core.Services; - using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils; /// /// Services implementation. /// - internal sealed class Services : PlatformTarget, IServices + internal sealed class Services : PlatformTargetAdapter, IServices { /** */ private const int OpDeploy = 1; @@ -87,13 +84,12 @@ namespace Apache.Ignite.Core.Impl.Services /// Initializes a new instance of the class. /// /// Target. - /// Marshaller. /// Cluster group. /// Invoker binary flag. /// Server binary flag. - public Services(IUnmanagedTarget target, Marshaller marsh, IClusterGroup clusterGroup, + public Services(IPlatformTargetInternal target, IClusterGroup clusterGroup, bool keepBinary, bool srvKeepBinary) - : base(target, marsh) + : base(target) { Debug.Assert(clusterGroup != null); @@ -108,7 +104,7 @@ namespace Apache.Ignite.Core.Impl.Services if (_keepBinary) return this; - return new Services(Target, Marshaller, _clusterGroup, true, _srvKeepBinary); + return new Services(Target, _clusterGroup, true, _srvKeepBinary); } /** */ @@ -117,7 +113,7 @@ namespace Apache.Ignite.Core.Impl.Services if (_srvKeepBinary) return this; - return new Services(DoOutOpObject(OpWithServerKeepBinary), Marshaller, _clusterGroup, _keepBinary, true); + return new Services(DoOutOpObject(OpWithServerKeepBinary), _clusterGroup, _keepBinary, true); } /** */ @@ -372,12 +368,13 @@ namespace Apache.Ignite.Core.Impl.Services /// /// Invocation result. /// - private unsafe object InvokeProxyMethod(IUnmanagedTarget proxy, MethodBase method, object[] args, + private object InvokeProxyMethod(IPlatformTargetInternal proxy, MethodBase method, object[] args, Platform platform) { return DoOutInOp(OpInvokeMethod, writer => ServiceProxySerializer.WriteProxyMethod(writer, method, args, platform), - (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary), proxy.Target); + (stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary), + proxy); } /// http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs index 4ddbc6d..4dd7f9f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs @@ -22,13 +22,12 @@ namespace Apache.Ignite.Core.Impl.Transactions using System.Threading.Tasks; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Impl.Binary; - using Apache.Ignite.Core.Impl.Unmanaged; using Apache.Ignite.Core.Transactions; /// /// Transactions facade. /// - internal class TransactionsImpl : PlatformTarget, ITransactions + internal class TransactionsImpl : PlatformTargetAdapter, ITransactions { /** */ private const int OpCacheConfigParameters = 1; @@ -82,29 +81,19 @@ namespace Apache.Ignite.Core.Impl.Transactions /// Initializes a new instance of the class. /// /// Target. - /// Marshaller. /// Local node id. - public TransactionsImpl(IUnmanagedTarget target, Marshaller marsh, - Guid localNodeId) : base(target, marsh) + public TransactionsImpl(IPlatformTargetInternal target, Guid localNodeId) : base(target) { _localNodeId = localNodeId; - TransactionConcurrency concurrency = default(TransactionConcurrency); - TransactionIsolation isolation = default(TransactionIsolation); - TimeSpan timeout = default(TimeSpan); + var res = target.OutStream(OpCacheConfigParameters, reader => Tuple.Create( + (TransactionConcurrency) reader.ReadInt(), + (TransactionIsolation) reader.ReadInt(), + reader.ReadLongAsTimespan())); - DoInOp(OpCacheConfigParameters, stream => - { - var reader = marsh.StartUnmarshal(stream).GetRawReader(); - - concurrency = (TransactionConcurrency) reader.ReadInt(); - isolation = (TransactionIsolation) reader.ReadInt(); - timeout = reader.ReadLongAsTimespan(); - }); - - _dfltConcurrency = concurrency; - _dfltIsolation = isolation; - _dfltTimeout = timeout; + _dfltConcurrency = res.Item1; + _dfltIsolation = res.Item2; + _dfltTimeout = res.Item3; } /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs index 1720a79..f96157c 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs @@ -63,6 +63,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamAsync")] public static extern void TargetInStreamAsync(void* ctx, void* target, int opType, long memPtr); + [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamOutObjectAsync")] + public static extern void* TargetInStreamOutObjectAsync(void* ctx, void* target, int opType, long memPtr); + [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAcquire")] public static extern void* Acquire(void* ctx, void* target); http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs index 2400390..819eda2 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs @@ -678,7 +678,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged binaryReceiver.Deserialize(); if (receiver != null) - receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx, cache), stream, keepBinary); + { + var target = new PlatformJniTarget(new UnmanagedNonReleaseableTarget(_ctx, cache), + _ignite.Marshaller); + receiver.Receive(_ignite, target, stream, keepBinary); + } return 0; } @@ -1171,9 +1175,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged if (affBase != null) { - var baseFunc0 = UU.Acquire(_ctx, baseFunc); + var baseFunc0 = new PlatformJniTarget(UU.Acquire(_ctx, baseFunc), _ignite.Marshaller); - affBase.SetBaseFunction(new PlatformAffinityFunction(baseFunc0, _ignite.Marshaller)); + affBase.SetBaseFunction(new PlatformAffinityFunction(baseFunc0)); } return _handleRegistry.Allocate(func); http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs index a38cf2f..b6e6582 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs @@ -175,6 +175,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged JNI.TargetInStreamAsync(target.Context, target.Target, opType, memPtr); } + internal static IUnmanagedTarget TargetInStreamOutObjectAsync(IUnmanagedTarget target, int opType, long memPtr) + { + void* res = JNI.TargetInStreamOutObjectAsync(target.Context, target.Target, opType, memPtr); + + return target.ChangeTarget(res); + } + #endregion #region NATIVE METHODS: MISCELANNEOUS http://git-wip-us.apache.org/repos/asf/ignite/blob/89bba2fa/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs index 621e604..6f5596a 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Interop/IPlatformTarget.cs @@ -18,6 +18,7 @@ namespace Apache.Ignite.Core.Interop { using System; + using System.Threading; using System.Threading.Tasks; using Apache.Ignite.Core.Binary; @@ -99,5 +100,19 @@ namespace Apache.Ignite.Core.Interop /// Task. Task DoOutOpAsync(int type, Action writeAction, Func readAction); + + /// + /// Performs asynchronous operation. + /// + /// Result type + /// Operation type code. + /// Write action (can be null). + /// Read function (can be null). + /// The cancellation token. + /// + /// Task. + /// + Task DoOutOpAsync(int type, Action writeAction, + Func readAction, CancellationToken cancellationToken); } }