You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/03/05 01:52:15 UTC

svn commit: r1078221 - /directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java

Author: elecharny
Date: Sat Mar  5 00:52:15 2011
New Revision: 1078221

URL: http://svn.apache.org/viewvc?rev=1078221&view=rev
Log:
Used a AtomicBoolean instead of a simple boolean to remove some potential synchronization problem

Modified:
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1078221&r1=1078220&r2=1078221&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Sat Mar  5 00:52:15 2011
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
@@ -83,7 +84,7 @@ public abstract class AbstractStore<E, I
     protected URI partitionPath;
 
     /** true if we sync disks on every write operation */
-    protected boolean isSyncOnWrite = true;
+    protected AtomicBoolean isSyncOnWrite = new AtomicBoolean( true );
 
     /** The store cache size */
     protected int cacheSize = DEFAULT_CACHE_SIZE;
@@ -187,13 +188,13 @@ public abstract class AbstractStore<E, I
     public void setSyncOnWrite( boolean isSyncOnWrite )
     {
         protect( "syncOnWrite" );
-        this.isSyncOnWrite = isSyncOnWrite;
+        this.isSyncOnWrite.set( isSyncOnWrite );
     }
 
 
     public boolean isSyncOnWrite()
     {
-        return isSyncOnWrite;
+        return isSyncOnWrite.get();
     }
 
 
@@ -1012,7 +1013,7 @@ public abstract class AbstractStore<E, I
 
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1059,7 +1060,7 @@ public abstract class AbstractStore<E, I
         updateCsnIndex( entry, id );
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1100,7 +1101,7 @@ public abstract class AbstractStore<E, I
         updateCsnIndex( entry, id );
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1156,7 +1157,7 @@ public abstract class AbstractStore<E, I
 
         master.delete( id );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1287,7 +1288,7 @@ public abstract class AbstractStore<E, I
 
         master.put( id, entry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1347,7 +1348,7 @@ public abstract class AbstractStore<E, I
         rename( oldDn, newRdn, deleteOldRdn, modifiedEntry );
         moveAndRename( oldDn, oldId, newSuperiorDn, newRdn, modifiedEntry );
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }
@@ -1447,7 +1448,7 @@ public abstract class AbstractStore<E, I
             master.put( entryId, modifiedEntry );
         }
 
-        if ( isSyncOnWrite )
+        if ( isSyncOnWrite.get() )
         {
             sync();
         }