@Test public void testAddAndGet() { MappedAtomicInteger value = getRandomStoredInteger(); int add = Random.getInt(); int expected = value.get() + add; Assert.assertEquals(expected, value.addAndGet(add)); }
public int addAndGet(int amount) { FileLock lock = lock(); try { int value = getUnsafe(); value = value + amount; return setUnsafe(value); } finally { FileLocks.release(lock); } }
MappedAtomicInteger { public int addAndGet(int amount) { FileLock lock = lock(); try { int value = getUnsafe(); value = value + amount; return setUnsafe(value); } finally { FileLocks.release(lock); } } }
MappedAtomicInteger { public int addAndGet(int amount) { FileLock lock = lock(); try { int value = getUnsafe(); value = value + amount; return setUnsafe(value); } finally { FileLocks.release(lock); } } MappedAtomicInteger(FileChannel channel);  MappedAtomicInteger(FileChannel channel, int position);  MappedAtomicInteger(String address);  MappedAtomicInteger(String address, int position); }
MappedAtomicInteger { public int addAndGet(int amount) { FileLock lock = lock(); try { int value = getUnsafe(); value = value + amount; return setUnsafe(value); } finally { FileLocks.release(lock); } } MappedAtomicInteger(FileChannel channel);  MappedAtomicInteger(FileChannel channel, int position);  MappedAtomicInteger(String address);  MappedAtomicInteger(String address, int position); int addAndGet(int amount); @Override void finalize(); int get(); void set(int value); void setAndSync(int value); void sync(); }
MappedAtomicInteger { public int addAndGet(int amount) { FileLock lock = lock(); try { int value = getUnsafe(); value = value + amount; return setUnsafe(value); } finally { FileLocks.release(lock); } } MappedAtomicInteger(FileChannel channel);  MappedAtomicInteger(FileChannel channel, int position);  MappedAtomicInteger(String address);  MappedAtomicInteger(String address, int position); int addAndGet(int amount); @Override void finalize(); int get(); void set(int value); void setAndSync(int value); void sync();  }