Skip to content

Commit

Permalink
Make SequenceLockStressIT reentrant.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Apr 27, 2018
1 parent c273bbd commit 87a8c48
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -21,6 +21,7 @@

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

Expand All @@ -35,28 +36,35 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.neo4j.memory.GlobalMemoryTracker;
import org.neo4j.test.rule.RepeatRule;
import org.neo4j.unsafe.impl.internal.dragons.UnsafeUtil;

public class SequenceLockStressIT
{
private static final ExecutorService executor = Executors.newCachedThreadPool( new DaemonThreadFactory() );
private static ExecutorService executor;
private static long lockAddr;

@BeforeClass
public static void initialise()
{
lockAddr = UnsafeUtil.allocateMemory( Long.BYTES );
executor = Executors.newCachedThreadPool( new DaemonThreadFactory() );
}

@AfterClass
public static void shutDownExecutor()
public static void cleanup()
{
executor.shutdown();
UnsafeUtil.free( lockAddr, Long.BYTES, GlobalMemoryTracker.INSTANCE );
}

@Rule
public RepeatRule repeatRule = new RepeatRule();

private long lockAddr;

@Before
public void allocateLock()
{
lockAddr = UnsafeUtil.allocateMemory( Long.BYTES );
UnsafeUtil.putLong( lockAddr, 0 );
}

Expand Down

0 comments on commit 87a8c48

Please sign in to comment.