예제 #1
0
파일: Log.cs 프로젝트: pbazydlo/bluepath
        public static DateTime AssureTimeMonotonicity(DateTime currentTime, IExtendedStorage storage, string storageKey)
        {
            using (var l = storage.AcquireLock(string.Format("{0}_lock", storageKey)))
            {
                var previousTime = default(DateTime);
                try
                {
                    previousTime = storage.Retrieve<DateTime>(storageKey);
                }
                catch
                {
                }

                if (currentTime <= previousTime)
                {
                    currentTime = previousTime.AddMilliseconds(1);
                }

                storage.StoreOrUpdate(storageKey, currentTime);
            }

            return currentTime;
        }