예제 #1
0
 public InMemoryDispatcher(InMemoryState state) : base(state)
 {
     _thread = new Thread(DoWork)
     {
         IsBackground = true,
         Name         = "Hangfire:InMemoryDispatcher"
     };
     _thread.Start();
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 public InMemoryDispatcherBase(InMemoryState state)
 {
     _state = state ?? throw new ArgumentNullException(nameof(state));
 }