Beispiel #1
0
        public Emulation()
        {
            MasterTimeSource = new MasterTimeSource();
            HostMachine      = new HostMachine();
            MACRepository    = new MACRepository();
            ExternalsManager = new ExternalsManager();
            ExternalsManager.AddExternal(HostMachine, HostMachine.HostMachineName);
            Connector                = new Connector();
            FileFetcher              = new CachingFileFetcher();
            CurrentLogger            = Logger.GetLogger();
            randomGenerator          = new Lazy <PseudorandomNumberGenerator>(() => new PseudorandomNumberGenerator());
            nameCache                = new LRUCache <object, Tuple <string, string> >(NameCacheSize);
            peripheralToMachineCache = new LRUCache <IPeripheral, Machine>(PeripheralToMachineCacheSize);

            machs            = new FastReadConcurrentTwoWayDictionary <string, Machine>();
            machs.ItemAdded += (name, machine) =>
            {
                machine.StateChanged       += OnMachineStateChanged;
                machine.PeripheralsChanged += (m, e) =>
                {
                    if (e.Operation != PeripheralsChangedEventArgs.PeripheralChangeType.Addition)
                    {
                        nameCache.Invalidate();
                        peripheralToMachineCache.Invalidate();
                    }
                };

                OnMachineAdded(machine);
            };

            machs.ItemRemoved += (name, machine) =>
            {
                machine.StateChanged -= OnMachineStateChanged;
                nameCache.Invalidate();
                peripheralToMachineCache.Invalidate();

                OnMachineRemoved(machine);
            };
            BackendManager = new BackendManager();
            BlobManager    = new BlobManager();
            theBag         = new Dictionary <string, object>();
        }
Beispiel #2
0
        public Emulation()
        {
            syncDomains      = new List <ISynchronizationDomain>();
            HostMachine      = new HostMachine();
            MACRepository    = new MACRepository();
            ExternalsManager = new ExternalsManager();
            ExternalsManager.AddExternal(HostMachine, HostMachine.HostMachineName);
            Connector     = new Connector();
            FileFetcher   = new CachingFileFetcher();
            CurrentLogger = Logger.GetLogger();
            nameCache     = new LRUCache <object, Tuple <string, string> >(NameCacheSize);

            machs            = new FastReadConcurrentTwoWayDictionary <string, Machine>();
            machs.ItemAdded += (name, machine) =>
            {
                machine.StateChanged       += OnMachineStateChanged;
                machine.PeripheralsChanged += (m, e) =>
                {
                    if (e.Operation != PeripheralsChangedEventArgs.PeripheralChangeType.Addition)
                    {
                        nameCache.Invalidate();
                    }
                };

                OnMachineAdded(machine);
            };

            machs.ItemRemoved += (name, machine) =>
            {
                machine.StateChanged -= OnMachineStateChanged;
                nameCache.Invalidate();

                OnMachineRemoved(machine);
            };
            BackendManager = new BackendManager();
            BlobManager    = new BlobManager();
            theBag         = new Dictionary <string, object>();
        }