public RxBufNaive(Node n, Evictor ev, Acceptor a) { m_n = n; m_ev = ev; m_a = a; switch (Config.rxbuf_mode) { case RxBufMode.JIT: m_rx_jit_buf = new Flit[Config.rxbuf_size]; for (int i = 0; i < m_rx_jit_buf.Length; i++) m_rx_jit_buf[i] = null; break; case RxBufMode.PSA: m_rx_psa_buf = new Packet[Config.rxbuf_size / Config.router.maxPacketSize]; m_rx_psa_state = new PSAState[m_rx_psa_buf.Length, Config.router.maxPacketSize]; m_rx_psa_flits = new Flit[m_rx_psa_buf.Length, Config.router.maxPacketSize]; for (int i = 0; i < m_rx_psa_buf.Length; i++) { m_rx_psa_buf[i] = null; for (int j = 0; j < Config.router.maxPacketSize; j++) { m_rx_psa_state[i,j] = PSAState.EMPTY; m_rx_psa_flits[i,j] = null; } } break; case RxBufMode.NONE: break; } }
public void Schedule(Evictor task, TimeSpan delay, TimeSpan period) { this.ThrowIfDisposed(); void ExecuteTask(Evictor ev, TimeSpan per) { ev.Run(); if (_tasks.ContainsKey(ev)) // canceled { _tasks[ev] = _timer.NewTimeout(to => ExecuteTask(ev, per), delay); } } this.Cancel(task); lock (this) { var r = _timer.NewTimeout(timeout => { ExecuteTask(task, period); }, delay); _tasks.Add(task, r); } }
public void Cancel(Evictor task) { this.ThrowIfDisposed(); lock (typeof(EvictionTimer)) { if (_taskMap.TryGetValue(task, out Timer timer)) { _taskMap.Remove(task); timer.Dispose(); } } }
public void Cancel(Evictor task) { this.ThrowIfDisposed(); lock (this) { if (_tasks.TryGetValue(task, out ITimeout to)) { to.Cancel(); _tasks.Remove(task); } } }
public void Schedule(Evictor task, TimeSpan delay, TimeSpan period) { this.ThrowIfDisposed(); if (task == null) { return; } lock (typeof(EvictionTimer)) { if (_taskMap.TryGetValue(task, out Timer timer)) { timer.Change(delay, period); } else { var t = new Timer(state => task.Run(), null, delay, period); _taskMap[task] = t; } } }
public CacheService() { if (Environment.OSVersion.Version.Major >= 6) //windows 7 or above? { _workingSetCounter = new PerformanceCounter("Process", "Working Set - Private", Process.GetCurrentProcess().ProcessName); } else { _workingSetCounter = new PerformanceCounter("Process", "Working Set", Process.GetCurrentProcess().ProcessName); } _localCache = new ConcurrentDictionary <string, ServerCacheItem>(Environment.ProcessorCount * 2, 1000); _evictor = new Evictor(_localCache); NodeState = NodeState.WaitingForNeighbourNode; //need to check if we recieve any information from neighbours in next 6 seconds. //such that they can move their data to me. note that default state is 'WaitingForOtherNode' heartBeatResetter = new Timer(TimerCallbackHeartBeatReset, null, 7000, Timeout.Infinite); _cacheItemRelocator = new CacheItemRelocator(_localCache); Trace.WriteLine("Initialized cacheService"); }