Skip to content

Commit

Permalink
minor - Make TransactionalStorage classes look the same
Browse files Browse the repository at this point in the history
  • Loading branch information
Fitzchak Yitzchaki committed Feb 16, 2012
1 parent 92fe4ed commit fe90daf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
3 changes: 1 addition & 2 deletions Raven.Storage.Esent/TransactionalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ private bool EnsureDatabaseIsCreatedAndAttachToDatabase()
}

[CLSCompliant(false)]
//[DebuggerHidden, DebuggerNonUserCode, DebuggerStepThrough]
public void Batch(Action<IStorageActionsAccessor> action)
{
if (disposerLock.IsReadLockHeld) // we are currently in a nested Batch call
Expand Down Expand Up @@ -363,7 +362,7 @@ public void Batch(Action<IStorageActionsAccessor> action)
if(disposed == false)
current.Value = null;
}
onCommit();// call user code after we exit the lock
onCommit(); // call user code after we exit the lock
}

[DebuggerHidden, DebuggerNonUserCode, DebuggerStepThrough]
Expand Down
31 changes: 18 additions & 13 deletions Raven.Storage.Managed/TransactionalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Diagnostics;
using System.IO;
using System.Threading;
using NLog;
using Newtonsoft.Json.Linq;
using Raven.Abstractions;
using Raven.Abstractions.Data;
Expand Down Expand Up @@ -89,7 +90,6 @@ public Guid Id
get; private set;
}

[DebuggerNonUserCode]
public void Batch(Action<IStorageActionsAccessor> action)
{
if (disposerLock.IsReadLockHeld) // we are currently in a nested Batch call
Expand All @@ -108,28 +108,33 @@ public void Batch(Action<IStorageActionsAccessor> action)
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();
}
ExecuteBatch(action);
}
finally
{
disposerLock.ExitReadLock();
if(disposed ==false)
if (disposed == false)
current.Value = null;
}
onCommit(); // call user code after we exit the lock
}

[DebuggerHidden, DebuggerNonUserCode, DebuggerStepThrough]
private void ExecuteBatch(Action<IStorageActionsAccessor> action)
{
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();
}
}

public void ExecuteImmediatelyOrRegisterForSyncronization(Action action)
{
if (current.Value == null)
Expand Down

0 comments on commit fe90daf

Please sign in to comment.