public CacheBlock GetCache(string key) { lock (Locker) { return(CachePool.Get(key)); } }
public static void RunTask(Action task, Action callback) { lock (CacheArgs) CacheArgs.Enqueue(ArgCache.Get().SetVal(task, callback)); if (!isRunning) { Run(); } }
protected override void OnUpdate() { semaphore.WaitOne(); lock (CacheArgs) { while (CacheArgs.Count != 0) { RunningArgs.Enqueue(CacheArgs.Dequeue()); } } while (RunningArgs.Count != 0) { Interlocked.Increment(ref ThreadCount); ThreadCache.Get().RunTask(RunningArgs.Dequeue()); } }
private static void ThreadLoop() { while (true) { eve.WaitOne(); lock (CacheArgs) { while (CacheArgs.Count != 0) { RunningArgs.Enqueue(CacheArgs.Dequeue()); } } while (RunningArgs.Count != 0) { ThreadCache.Get().RunTask(RunningArgs.Dequeue()); } Thread.Sleep(5); Stop(); } }
public void CacheTableRegisterTest() { //注册缓存表 _pool.Register <TestTable>(); Assert.IsNotNull(_pool.Get <TestTable>()); }