public virtual void TryProcessNext()
        {
            long currentTime = SystemUtil.GetRelativeTimeMillis();

            if (currentTime - lastProcessedTime.Get() > waitTime.GetTime())
            {
                lastProcessedTime.Set(SystemUtil.GetRelativeTimeMillis());
                V data;
                lock (cache) {
                    data = cache.RetrieveNext();
                }
                if (data != null)
                {
                    bool successful;
                    lock (processLock) {
                        successful = TryProcess(data);
                    }
                    if (successful)
                    {
                        OnSuccess(data);
                    }
                    else
                    {
                        lock (cache) {
                            cache.Put(data);
                        }
                        OnFailure(data);
                    }
                }
            }
        }
예제 #2
0
 private static void TestCache(IEventDataCache <String, DataCacheTest.SimpleData> cache, IList <DataCacheTest.SimpleData
                                                                                                > input, IList <DataCacheTest.SimpleData> expectedOutput)
 {
     foreach (DataCacheTest.SimpleData @event in input)
     {
         cache.Put(@event);
     }
     foreach (DataCacheTest.SimpleData expected in expectedOutput)
     {
         DataCacheTest.SimpleData actual = cache.RetrieveNext();
         NUnit.Framework.Assert.AreEqual(expected.GetSignature(), actual.GetSignature());
         NUnit.Framework.Assert.AreEqual(expected.GetCount(), actual.GetCount());
     }
 }