public InMemoryDispatcher(InMemoryState state) : base(state) { _thread = new Thread(DoWork) { IsBackground = true, Name = "Hangfire:InMemoryDispatcher" }; _thread.Start(); }
protected void ExpireJobIndex(DateTime now, InMemoryState state) { BackgroundJobEntry entry; // TODO: Replace with actual expiration rules while (state._jobIndex.Count > 0 && (entry = state._jobIndex.Min).ExpireAt.HasValue && now >= entry.ExpireAt) { state.JobDelete(entry); } }
private static void CounterIncrement(InMemoryState state, string key, int value, TimeSpan?expireIn) { var counter = state.CounterGetOrAdd(key); counter.Value += value; if (counter.Value != 0) { if (expireIn.HasValue) { state.CounterExpire(counter, expireIn); } } else { state.CounterDelete(counter); } }
public InMemoryDispatcherBase(InMemoryState state) { _state = state ?? throw new ArgumentNullException(nameof(state)); }