Author: clebert.suconic(a)jboss.com
Date: 2009-12-09 13:59:05 -0500 (Wed, 09 Dec 2009)
New Revision: 8646
Modified:
trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
Log:
duh... removing extra synchronized block
Modified: trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-12-09 18:30:41 UTC
(rev 8645)
+++ trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2009-12-09 18:59:05 UTC
(rev 8646)
@@ -262,43 +262,40 @@
* */
public synchronized void flush()
{
- synchronized (this)
+ if (buffer.writerIndex() > 0)
{
- if (buffer.writerIndex() > 0)
+ int pos = buffer.writerIndex();
+
+ if (logRates)
{
- int pos = buffer.writerIndex();
+ bytesFlushed.addAndGet(pos);
+ }
- if (logRates)
- {
- bytesFlushed.addAndGet(pos);
- }
+ ByteBuffer bufferToFlush = bufferObserver.newBuffer(bufferSize, pos);
- ByteBuffer bufferToFlush = bufferObserver.newBuffer(bufferSize, pos);
+ // Putting a byteArray on a native buffer is much faster, since it will do in a
single native call.
+ // Using bufferToFlush.put(buffer) would make several append calls for each
byte
- // Putting a byteArray on a native buffer is much faster, since it will do in
a single native call.
- // Using bufferToFlush.put(buffer) would make several append calls for each
byte
+ bufferToFlush.put(buffer.toByteBuffer().array(), 0, pos);
- bufferToFlush.put(buffer.toByteBuffer().array(), 0, pos);
+ if (bufferToFlush != null)
+ {
+ bufferObserver.flushBuffer(bufferToFlush, pendingSync, callbacks);
+ }
- if (bufferToFlush != null)
- {
- bufferObserver.flushBuffer(bufferToFlush, pendingSync, callbacks);
- }
+ lastFlushTime.set(System.nanoTime());
- lastFlushTime.set(System.nanoTime());
+ pendingSync = false;
- pendingSync = false;
+ callbacks = new LinkedList<IOAsyncTask>();
- callbacks = new LinkedList<IOAsyncTask>();
+ buffer.clear();
- buffer.clear();
+ bufferLimit = 0;
- bufferLimit = 0;
+ flushesDone.incrementAndGet();
- flushesDone.incrementAndGet();
-
- timer.pauseSpin();
- }
+ timer.pauseSpin();
}
}
Show replies by date