/// <summary> /// Tries to open a named event. /// </summary> /// <param name="globalMemoryRegion"></param> /// <param name="memoryRegionId"></param> /// <param name="namedEvent"></param> /// <returns></returns> public static bool TryOpenExisting( this GlobalMemoryRegion globalMemoryRegion, MlosInternal.MemoryRegionId memoryRegionId, out NamedEvent namedEvent) { MlosInternal.RegisteredNamedEventConfig.CodegenKey namedEventLookupKey = default; namedEventLookupKey.MemoryRegionId = memoryRegionId; // Locate named event config. // SharedConfig <MlosProxyInternal.RegisteredNamedEventConfig> registeredNamedEventSharedConfig = SharedConfigManager.Lookup(globalMemoryRegion.SharedConfigDictionary, namedEventLookupKey); if (!registeredNamedEventSharedConfig.HasSharedConfig) { namedEvent = null; return(false); } // Config exists, create a named event. // MlosProxyInternal.RegisteredNamedEventConfig registeredNamedEventConfig = registeredNamedEventSharedConfig.Config; namedEvent = NamedEvent.CreateOrOpen(registeredNamedEventConfig.EventName.Value); return(true); }
/// <summary> /// Tries to open a shared memory map. /// </summary> /// <param name="globalMemoryRegion"></param> /// <param name="memoryRegionId"></param> /// <param name="sharedMemoryMapView"></param> /// <returns></returns> public static bool TryOpenExisting( this GlobalMemoryRegion globalMemoryRegion, MlosInternal.MemoryRegionId memoryRegionId, out SharedMemoryMapView sharedMemoryMapView) { MlosInternal.RegisteredMemoryRegionConfig.CodegenKey registeredMemoryLookupKey = default; registeredMemoryLookupKey.MemoryRegionId = memoryRegionId; // Locate shared memory region config. // SharedConfig <MlosProxyInternal.RegisteredMemoryRegionConfig> registeredMemoryRegionSharedConfig = SharedConfigManager.Lookup(globalMemoryRegion.SharedConfigDictionary, registeredMemoryLookupKey); if (!registeredMemoryRegionSharedConfig.HasSharedConfig) { sharedMemoryMapView = null; return(false); } // Config exists, create a shared config memory region. // MlosProxyInternal.RegisteredMemoryRegionConfig registeredMemoryRegionConfig = registeredMemoryRegionSharedConfig.Config; sharedMemoryMapView = SharedMemoryMapView.OpenExisting( registeredMemoryRegionConfig.MemoryMapName.Value, registeredMemoryRegionConfig.MemoryRegionSize); return(true); }