Fix a thread safety issue ThreadLocalCopies triggered when running StringsMapMain.

This commit is contained in:
Peter Lawrey
2014-11-12 21:04:42 +00:00
parent d296d3d3b6
commit f5f2139428
4 changed files with 11 additions and 6 deletions
+1 -1
View File
@@ -46,7 +46,7 @@
<dependency>
<groupId>net.openhft</groupId>
<artifactId>lang</artifactId>
<version>6.4.13</version>
<version>6.4.14-SNAPSHOT</version>
</dependency>
<dependency>
@@ -820,7 +820,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, KI>,
/**
* called from a remote node when it wishes to propagate a remove event
*/
private void remotePut(@NotNull final Bytes inBytes, long hash2,
void remotePut(@NotNull final Bytes inBytes, long hash2,
final byte identifier, final long timestamp,
long valuePos, long valueLimit) {
@@ -1096,7 +1096,7 @@ final class TcpReplicator extends AbstractChannelReplicator implements Closeable
* @param attached
* @throws InterruptedException
*/
private void entriesFromBuffer(Attached attached) throws InterruptedException, IOException {
void entriesFromBuffer(Attached attached) throws InterruptedException, IOException {
for (; ; ) {
out.limit(in.position());
@@ -81,12 +81,17 @@ public class StringsMapMain {
long t1 = System.nanoTime();
map.put(key, value);
long t2 = System.nanoTime();
map.getUsing(key, value2);
if (stateless) {
value.setLength(0);
value.append(map.get(key));
} else {
map.getUsing(key, value);
}
long t3 = System.nanoTime();
puts += t2 - t1;
gets += t3 - t2;
if (t2 - t1 > lastAveragePut * 100 || t3 - t2 > lastAverageGet * 100)
System.out.printf("Took put/get took %.1f/%.1f us%n", (t2 - t1) / 1e3, (t3 - t2) / 1e3);
// if (t2 - t1 > lastAveragePut * 100 || t3 - t2 > lastAverageGet * 100)
// System.out.printf("Took put/get took %.1f/%.1f us%n", (t2 - t1) / 1e3, (t3 - t2) / 1e3);
}
lastAveragePut = puts / entries;
lastAverageGet = gets / entries;