コード例 #1
0
        /// <param name="context">Context.</param>
        public void SetContext(void *context)
        {
            Debug.Assert(context != null);
            Debug.Assert(_ctx == null);

            _ctx = new UnmanagedContext(context);
        }
コード例 #2
0
ファイル: UnmanagedUtils.cs プロジェクト: wmz7year/ignite
        internal static void IgnitionStart(UnmanagedContext ctx, string cfgPath, string gridName,
            bool clientMode, bool userLogger)
        {
            using (var mem = IgniteManager.Memory.Allocate().GetStream())
            {
                mem.WriteBool(clientMode);
                mem.WriteBool(userLogger);

                sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfgPath);
                sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);

                try
                {
                    // OnStart receives the same InteropProcessor as here (just as another GlobalRef) and stores it.
                    // Release current reference immediately.
                    void* res = JNI.IgnitionStart(ctx.NativeContext, cfgPath0, gridName0, InteropFactoryId,
                        mem.SynchronizeOutput());

                    JNI.Release(res);
                }
                finally
                {
                    Marshal.FreeHGlobal(new IntPtr(cfgPath0));
                    Marshal.FreeHGlobal(new IntPtr(gridName0));
                }
            }
        }
コード例 #3
0
ファイル: UnmanagedUtils.cs プロジェクト: senior7515/ignite
        internal static void IgnitionStart(UnmanagedContext ctx, string cfgPath, string gridName,
                                           bool clientMode, bool userLogger)
        {
            using (var mem = IgniteManager.Memory.Allocate().GetStream())
            {
                mem.WriteBool(clientMode);
                mem.WriteBool(userLogger);

                sbyte *cfgPath0  = IgniteUtils.StringToUtf8Unmanaged(cfgPath);
                sbyte *gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);

                try
                {
                    // OnStart receives the same InteropProcessor as here (just as another GlobalRef) and stores it.
                    // Release current reference immediately.
                    void *res = JNI.IgnitionStart(ctx.NativeContext, cfgPath0, gridName0, InteropFactoryId,
                                                  mem.SynchronizeOutput());

                    JNI.Release(res);
                }
                finally
                {
                    Marshal.FreeHGlobal(new IntPtr(cfgPath0));
                    Marshal.FreeHGlobal(new IntPtr(gridName0));
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ctx">Context.</param>
 /// <param name="target">Target.</param>
 public UnmanagedTarget(UnmanagedContext ctx, void* target)
     : base(IntPtr.Zero)
 {
     _ctx = ctx;
     
     SetHandle(new IntPtr(target));
 }
コード例 #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ctx">Context.</param>
        /// <param name="target">Target.</param>
        public UnmanagedTarget(UnmanagedContext ctx, void *target)
            : base(IntPtr.Zero)
        {
            _ctx = ctx;

            SetHandle(new IntPtr(target));
        }
コード例 #6
0
        private void OnStop(void *target)
        {
            Marshal.FreeHGlobal(_cbsPtr);

            // ReSharper disable once ImpureMethodCallOnReadonlyValueField
            _thisHnd.Free();

            // Allow context to be collected, which will cause resource cleanup in finalizer.
            _ctx = null;
        }
コード例 #7
0
        private void OnStop(void *target)
        {
            Marshal.FreeHGlobal(_cbsPtr);

            // ReSharper disable once ImpureMethodCallOnReadonlyValueField
            _thisHnd.Free();

            // Allow context to be collected, which will cause resource cleanup in finalizer.
            _ctx = null;

            // Notify grid
            var ignite = _ignite;

            if (ignite != null)
            {
                ignite.AfterNodeStop();
            }
        }
コード例 #8
0
ファイル: UnmanagedUtils.cs プロジェクト: iveselovskiy/ignite
        internal static IUnmanagedTarget IgnitionStart(UnmanagedContext ctx, string cfgPath, string gridName,
            bool clientMode)
        {
            using (var mem = IgniteManager.Memory.Allocate().GetStream())
            {
                mem.WriteBool(clientMode);

                sbyte* cfgPath0 = IgniteUtils.StringToUtf8Unmanaged(cfgPath);
                sbyte* gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);

                try
                {
                    void* res = JNI.IgnitionStart(ctx.NativeContext, cfgPath0, gridName0, InteropFactoryId,
                        mem.SynchronizeOutput());

                    return new UnmanagedTarget(ctx, res);
                }
                finally
                {
                    Marshal.FreeHGlobal(new IntPtr(cfgPath0));
                    Marshal.FreeHGlobal(new IntPtr(gridName0));
                }
            }
        }
コード例 #9
0
        internal static IUnmanagedTarget IgnitionStart(UnmanagedContext ctx, string cfgPath, string gridName,
                                                       bool clientMode)
        {
            using (var mem = IgniteManager.Memory.Allocate().GetStream())
            {
                mem.WriteBool(clientMode);

                sbyte *cfgPath0  = IgniteUtils.StringToUtf8Unmanaged(cfgPath);
                sbyte *gridName0 = IgniteUtils.StringToUtf8Unmanaged(gridName);

                try
                {
                    void *res = JNI.IgnitionStart(ctx.NativeContext, cfgPath0, gridName0, InteropFactoryId,
                                                  mem.SynchronizeOutput());

                    return(new UnmanagedTarget(ctx, res));
                }
                finally
                {
                    Marshal.FreeHGlobal(new IntPtr(cfgPath0));
                    Marshal.FreeHGlobal(new IntPtr(gridName0));
                }
            }
        }
コード例 #10
0
ファイル: UnmanagedUtils.cs プロジェクト: vladdou/ignite
        internal static IUnmanagedTarget Acquire(UnmanagedContext ctx, void *target)
        {
            void *target0 = JNI.Acquire(ctx.NativeContext, target);

            return(new UnmanagedTarget(ctx, target0));
        }
コード例 #11
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ctx">Context.</param>
 /// <param name="target">Target.</param>
 public UnmanagedNonReleaseableTarget(UnmanagedContext ctx, void* target)
 {
     _ctx = ctx;
     _target = target;
 }
コード例 #12
0
ファイル: UnmanagedUtils.cs プロジェクト: iveselovskiy/ignite
        internal static IUnmanagedTarget Acquire(UnmanagedContext ctx, void* target)
        {
            void* target0 = JNI.Acquire(ctx.NativeContext, target);

            return new UnmanagedTarget(ctx, target0);
        }
コード例 #13
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="ctx">Context.</param>
 /// <param name="target">Target.</param>
 public UnmanagedNonReleaseableTarget(UnmanagedContext ctx, void *target)
 {
     _ctx    = ctx;
     _target = target;
 }