Inheritance: IStorageActionsAccessor
示例#1
0
 public void Batch(Action<IStorageActionsAccessor> action)
 {
     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
     }
     if(current.Value != null)
     {
         action(current.Value);
         return;
     }
     disposerLock.EnterReadLock();
     try
     {
         Interlocked.Exchange(ref lastUsageTime, DateTime.Now.ToBinary());
         using (tableStroage.BeginTransaction())
         {
             var storageActionsAccessor = new StorageActionsAccessor(tableStroage, uuidGenerator);
             current.Value = storageActionsAccessor;
             action(current.Value);
             tableStroage.Commit();
             storageActionsAccessor.InvokeOnCommit();
             onCommit();
         }
     }
     finally
     {
         disposerLock.ExitReadLock();
         current.Value = null;
     }
 }
示例#2
0
 public void Batch(Action<IStorageActionsAccessor> action)
 {
     var tableStorage = new TableStorage(persistentSource);
     tableStorage.Initialze();
     var accessor = new StorageActionsAccessor(tableStorage, new DummyUuidGenerator(), new AbstractDocumentCodec[0]);
     action(accessor);
 }
示例#3
0
 public void Write(Action <StorageActionsAccessor> func)
 {
     lock (locker)
     {
         using (var reader = OpenReader())
         {
             var mutator  = new StorageMutator(writer, reader, transaction);
             var viewer   = new StorageReader(reader, transaction);
             var accessor = new StorageActionsAccessor(mutator, viewer, reader, writer);
             func(accessor);
             mutator.Flush();
             var storageTransaction = mutator.CreateTransaction();
             if (transaction.Equals(storageTransaction))
             {
                 return;
             }
             WriteTransaction(storageTransaction);
             writer.Flush(true);
             transaction = storageTransaction;
             accessor.RaiseCommitEvent();
             if (onCommit != null)
             {
                 onCommit();
             }
         }
     }
 }
示例#4
0
        public void Batch(Action <IStorageActionsAccessor> action)
        {
            if (current.Value != null)
            {
                action(current.Value);
                return;
            }
            disposerLock.EnterReadLock();
            try
            {
                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
                }

                Interlocked.Exchange(ref lastUsageTime, DateTime.Now.ToBinary());
                using (tableStroage.BeginTransaction())
                {
                    var storageActionsAccessor = new StorageActionsAccessor(tableStroage, uuidGenerator, DocumentCodecs, documentCacher);
                    current.Value = storageActionsAccessor;
                    action(current.Value);
                    tableStroage.Commit();
                    storageActionsAccessor.InvokeOnCommit();
                    onCommit();
                }
            }
            finally
            {
                disposerLock.ExitReadLock();
                current.Value = null;
            }
        }
 public void Batch(Action<IStorageActionsAccessor> action)
 {
     var tableStorage = new TableStorage(persistentSource);
     tableStorage.Initialze();
     var accessor = new StorageActionsAccessor(tableStorage);
     action(accessor);
 }
示例#6
0
 public void Batch(Action <IStorageActionsAccessor> action)
 {
     using (var tableStorage = new TableStorage(persistentSource))
     {
         tableStorage.Initialze();
         var accessor = new StorageActionsAccessor(tableStorage, new DummyUuidGenerator(), new OrderedPartCollection <AbstractDocumentCodec>());
         action(accessor);
     }
 }
示例#7
0
        public void Batch(Action<IStorageActionsAccessor> action)
        {
			using (var tableStorage = new TableStorage(persistentSource))
			{
				tableStorage.Initialze();
				var accessor = new StorageActionsAccessor(tableStorage, new DummyUuidGenerator(), new OrderedPartCollection<AbstractDocumentCodec>());
				action(accessor);
			}
        }
示例#8
0
 private void ExecuteBatch(Action <IStorageActionsAccessor> action)
 {
     Interlocked.Exchange(ref lastUsageTime, SystemTime.UtcNow.ToBinary());
     using (tableStroage.BeginTransaction())
     {
         var storageActionsAccessor = new StorageActionsAccessor(tableStroage, uuidGenerator, DocumentCodecs, documentCacher);
         current.Value = storageActionsAccessor;
         action(current.Value);
         storageActionsAccessor.SaveAllTasks();
         tableStroage.Commit();
         storageActionsAccessor.InvokeOnCommit();
     }
 }
示例#9
0
 private StorageActionsAccessor ExecuteBatch(Action <IStorageActionsAccessor> action)
 {
     Interlocked.Exchange(ref lastUsageTime, SystemTime.UtcNow.ToBinary());
     using (tableStorage.BeginTransaction())
     {
         var storageActionsAccessor = new StorageActionsAccessor(tableStorage, uuidGenerator, DocumentCodecs, documentCacher);
         if (disableBatchNesting.Value == null)
         {
             current.Value = storageActionsAccessor;
         }
         action(storageActionsAccessor);
         storageActionsAccessor.SaveAllTasks();
         tableStorage.Commit();
         return(storageActionsAccessor);
     }
 }
示例#10
0
        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
            {
                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
                }


                Interlocked.Exchange(ref lastUsageTime, SystemTime.Now.ToBinary());
                using (tableStroage.BeginTransaction())
                {
                    var storageActionsAccessor = new StorageActionsAccessor(tableStroage, uuidGenerator, DocumentCodecs, documentCacher);
                    current.Value = storageActionsAccessor;
                    action(current.Value);
                    storageActionsAccessor.SaveAllTasks();
                    tableStroage.Commit();
                    storageActionsAccessor.InvokeOnCommit();
                }
            }
            finally
            {
                disposerLock.ExitReadLock();
                if (disposed == false)
                {
                    current.Value = null;
                }
            }
            onCommit();             // call user code after we exit the lock
        }
示例#11
0
		private void ExecuteBatch(Action<IStorageActionsAccessor> action)
		{
			Interlocked.Exchange(ref lastUsageTime, SystemTime.UtcNow.ToBinary());
			using (tableStroage.BeginTransaction())
			{
				var storageActionsAccessor = new StorageActionsAccessor(tableStroage, uuidGenerator, DocumentCodecs, documentCacher);
				current.Value = storageActionsAccessor;
				action(current.Value);
				storageActionsAccessor.SaveAllTasks();
				storageActionsAccessor.InvokePreCommit();
				tableStroage.Commit();
				storageActionsAccessor.InvokeOnCommit();
			}
		}
示例#12
0
		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
			{
				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
				}
					

				Interlocked.Exchange(ref lastUsageTime, SystemTime.Now.ToBinary());
				using (tableStroage.BeginTransaction())
				{
					var storageActionsAccessor = new StorageActionsAccessor(tableStroage, uuidGenerator, DocumentCodecs, documentCacher);
					current.Value = storageActionsAccessor;
					action(current.Value);
					storageActionsAccessor.SaveAllTasks();
					tableStroage.Commit();
					storageActionsAccessor.InvokeOnCommit();
				}
			}
			finally
			{
				disposerLock.ExitReadLock();
				if(disposed ==false)
					current.Value = null;
			}
			onCommit(); // call user code after we exit the lock
		}
示例#13
0
		private StorageActionsAccessor ExecuteBatch(Action<IStorageActionsAccessor> action)
		{
			Interlocked.Exchange(ref lastUsageTime, SystemTime.UtcNow.ToBinary());
			using (tableStorage.BeginTransaction())
			{
				var storageActionsAccessor = new StorageActionsAccessor(tableStorage, uuidGenerator, DocumentCodecs, documentCacher);
				if (disableBatchNesting.Value == null)
					current.Value = storageActionsAccessor;
				action(storageActionsAccessor);
				storageActionsAccessor.SaveAllTasks();
				tableStorage.Commit();
				return storageActionsAccessor;
			}
		}
示例#14
0
		public void Write(Action<StorageActionsAccessor> func)
		{
			lock (locker)
			{
				using (var reader = OpenReader())
				{
					var mutator = new StorageMutator(writer, reader, transaction);
					var viewer = new StorageReader(reader, transaction);
					var accessor = new StorageActionsAccessor(mutator, viewer, reader, writer);
					func(accessor);
					mutator.Flush();
					var storageTransaction = mutator.CreateTransaction();
					if (transaction.Equals(storageTransaction))
						return;
					WriteTransaction(storageTransaction);
					writer.Flush(true);
					transaction = storageTransaction;
					accessor.RaiseCommitEvent();
					if (onCommit != null)
						onCommit();
				}
			}
		}