Beispiel #1
0
    public BaseSharedChannelBenchmark()
    {
        globalChannelMemoryRegionView = SharedMemoryRegionView.CreateNew <MlosProxyInternal.GlobalMemoryRegion>(GlobalMemoryMapName, SharedMemorySize);
        sharedChannelMemoryMapView    = SharedMemoryMapView.CreateNew(SharedChannelMemoryMapName, SharedMemorySize);

        MlosProxyInternal.GlobalMemoryRegion globalMemoryRegion = globalChannelMemoryRegionView.MemoryRegion();

        sharedChannel = new TestSharedChannel(sharedChannelMemoryMapView, globalMemoryRegion.ControlChannelSynchronization);

        settingsAssemblyManager.RegisterAssembly(typeof(MlosContext).Assembly);
        settingsAssemblyManager.RegisterAssembly(typeof(AssemblyInitializer).Assembly);

        // Preallocate class type messages to avoid heap allocations.
        //
        stringViewArray    = new StringViewArray();
        stringViewArray.Id = 1;
        stringViewArray.Strings[0].Value = "12345";
        stringViewArray.Strings[1].Value = "54321";
        stringViewArray.Strings[2].Value = "abc";
        stringViewArray.Strings[3].Value = "cba";
        stringViewArray.Strings[4].Value = "sbs";

        wideStringMultiMessage = new WideStringMultiMessage();
        wideStringMultiMessage.StringMessages[0].Id = 4;
        wideStringMultiMessage.StringMessages[0].Strings[0].Value = "Test_Name9876";
        wideStringMultiMessage.StringMessages[0].Strings[1].Value = "Test_Name19876";
        wideStringMultiMessage.StringMessages[0].Strings[2].Value = "Test_Name1239876";
        wideStringMultiMessage.StringMessages[0].Strings[3].Value = "Test_Name45659876";
        wideStringMultiMessage.StringMessages[0].Strings[4].Value = "Test_Name901239876";

        pointMessage.X = 4;
        pointMessage.Y = 5;
    }
Beispiel #2
0
        public SharedChannelTests()
        {
            // Load the registry settings assemblies.
            //
            _ = SettingsAssemblyInitializer.GetGlobalDispatchTable();

            // Initialize shared channel.
            //
            globalChannelMemoryRegionView = SharedMemoryRegionView.CreateNew <MlosProxyInternal.GlobalMemoryRegion>(GlobalMemoryMapName, SharedMemorySize);
            globalChannelMemoryRegionView.CleanupOnClose = true;
            sharedChannelMemoryMapView = SharedMemoryMapView.CreateNew(SharedChannelMemoryMapName, SharedMemorySize);
            sharedChannelMemoryMapView.CleanupOnClose = true;

            MlosProxyInternal.GlobalMemoryRegion globalMemoryRegion = globalChannelMemoryRegionView.MemoryRegion();

            sharedChannel = new TestSharedChannel(sharedChannelMemoryMapView, globalMemoryRegion.ControlChannelSynchronization);
        }
Beispiel #3
0
        public void VerifySharedMemoryMapUnlink()
        {
            // Create a new shared memory maps.
            //
            var newSharedChannelMemoryMap = SharedMemoryMapView.CreateNew(SharedMemoryMapName, SharedMemorySize);

            newSharedChannelMemoryMap.CleanupOnClose = true;
            newSharedChannelMemoryMap.Dispose();

            try
            {
                // Verify we can open already created shared memory.
                //
                using var openedSharedChannelMemoryMap      = SharedMemoryMapView.OpenExisting(SharedMemoryMapName, SharedMemorySize);
                openedSharedChannelMemoryMap.CleanupOnClose = true;

                Assert.False(true, "Shared memory map should be deleted");
            }
            catch (FileNotFoundException)
            {
                // We are expecting failure.
                //
            }
        }