Esempio n. 1
0
        /// <summary>
        /// Create JVM.
        /// </summary>
        /// <returns>JVM.</returns>
        private static void *CreateJvm(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
        {
            var ggHome = IgniteHome.Resolve(cfg);

            var cp = Classpath.CreateClasspath(ggHome, cfg, false);

            var jvmOpts = GetMergedJvmOptions(cfg);

            var hasGgHome = !string.IsNullOrWhiteSpace(ggHome);

            var opts = new sbyte *[1 + jvmOpts.Count + (hasGgHome ? 1 : 0)];

            int idx = 0;

            opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cp);

            if (hasGgHome)
            {
                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged("-DIGNITE_HOME=" + ggHome);
            }

            foreach (string cfgOpt in jvmOpts)
            {
                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cfgOpt);
            }

            try
            {
                IntPtr mem = Marshal.AllocHGlobal(opts.Length * 8);

                fixed(sbyte **opts0 = opts)
                {
                    PlatformMemoryUtils.CopyMemory(opts0, mem.ToPointer(), opts.Length * 8);
                }

                try
                {
                    return(UU.CreateContext(mem.ToPointer(), opts.Length, cbs.CallbacksPointer));
                }
                finally
                {
                    Marshal.FreeHGlobal(mem);
                }
            }
            finally
            {
                foreach (sbyte *opt in opts)
                {
                    Marshal.FreeHGlobal((IntPtr)opt);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create JVM.
        /// </summary>
        /// <returns>JVM.</returns>
        private static void *CreateJvm(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
        {
            var cp = Classpath.CreateClasspath(cfg);

            var jvmOpts = GetMergedJvmOptions(cfg);

            var opts = new sbyte *[1 + jvmOpts.Count];

            int idx = 0;

            opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cp);

            foreach (string cfgOpt in jvmOpts)
            {
                opts[idx++] = IgniteUtils.StringToUtf8Unmanaged(cfgOpt);
            }

            try
            {
                IntPtr mem = Marshal.AllocHGlobal(opts.Length * 8);

                fixed(sbyte **opts0 = opts)
                {
                    PlatformMemoryUtils.CopyMemory(opts0, mem.ToPointer(), opts.Length * 8);
                }

                try
                {
                    return(UU.CreateContext(mem.ToPointer(), opts.Length, cbs.CallbacksPointer));
                }
                finally
                {
                    Marshal.FreeHGlobal(mem);
                }
            }
            finally
            {
                foreach (sbyte *opt in opts)
                {
                    Marshal.FreeHGlobal((IntPtr)opt);
                }
            }
        }