Пример #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
        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
        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
        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
        internal static IUnmanagedTarget Acquire(UnmanagedContext ctx, void *target)
        {
            void *target0 = JNI.Acquire(ctx.NativeContext, target);

            return(new UnmanagedTarget(ctx, target0));
        }
 /// <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
        internal static IUnmanagedTarget Acquire(UnmanagedContext ctx, void* target)
        {
            void* target0 = JNI.Acquire(ctx.NativeContext, target);

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