Sync all modifications done by this thread. The internal concurrency design of this class is as follows: - Log items are written synchronized into an in-memory buffer, and each assigned a transaction ID. - When a thread (client) would like to sync all of its edits, logSync() uses a ThreadLocal transaction ID to determine what edit number must be synced to. - The isSyncRunning volatile boolean tracks whether a sync is currently under progress. The data is double-buffered within each edit log implementation so that in-memory writing can occur in parallel with the on-disk writing. Each sync occurs in three steps: 1. synchronized, it swaps the double buffer and sets the isSyncRunning flag. 2. unsynchronized, it flushes the data to storage 3. synchronized, it resets the flag and notifies anyone waiting on the sync. The lack of synchronization on step 2 allows other threads to continue to write into the memory buffer while the sync is in progress. Because this step is unsynchronized, actions that need to avoid concurrency with sync() should be synchronized and also call waitForSyncToFinish() before assuming they are running alone.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.