Raven.Storage.Esent.TransactionalStorage.Batch C# (CSharp) 메소드

Batch() 개인적인 메소드

private Batch ( Action action ) : void
action Action
리턴 void
		public void Batch(Action<IStorageActionsAccessor> action)
		{
			if (disposerLock.IsReadLockHeld) // we are currently in a nested Batch call
			{
				if (current.Value != null) // check again, just to be sure
				{
					action(current.Value);
					return;
				}
			}
			disposerLock.EnterReadLock();
			try
			{
				ExecuteBatch(action);
			}
			catch (EsentErrorException e)
			{
				if (disposed)
				{
					Trace.WriteLine("TransactionalStorage.Batch was called after it was disposed, call was ignored.");
					return; // this may happen if someone is calling us from the finalizer thread, so we can't even throw on that
				}
			
				switch (e.Error)
				{
					case JET_err.WriteConflict:
					case JET_err.SessionWriteConflict:
					case JET_err.WriteConflictPrimaryIndex:
						throw new ConcurrencyException("Concurrent modification to the same document are not allowed");
					default:
						throw;
				}
			}
			finally
			{
				disposerLock.ExitReadLock();
				if(disposed == false)
					current.Value = null;
			}
			onCommit();// call user code after we exit the lock
		}

Usage Example

예제 #1
0
		public static List<string> ReportOn(TransactionalStorage transactionalStorage)
		{
			var list = new List<string>();
			transactionalStorage.Batch(accessor =>
			{
				var session = ((StorageActionsAccessor)accessor).Inner.Session;
				var jetDbid = ((StorageActionsAccessor)accessor).Inner.Dbid;

				var dictionary = GetSizes(session, jetDbid);
				list.AddRange(dictionary.OrderByDescending(x => x.Item2).Select(l => l.Item1));
			});
			return list;
		}
All Usage Examples Of Raven.Storage.Esent.TransactionalStorage::Batch