@Test public void testMappedCache3() throws IOException { VanillaMappedCache<Integer> cache = new VanillaMappedCache(32, false); VanillaMappedBytes buffer = null; File file = null; for (int j = 0; j < 5; j++) { long start = System.nanoTime(); int maxRuns = 10000, runs; for (runs = 0; runs < maxRuns; runs++) { file = newTempraryFile("vmc-3-v" + runs, false); buffer = cache.put(runs, file, 256, runs); buffer.writeLong(0, 0x12345678); assertEquals(0x12345678L, buffer.readLong(0)); assertEquals(runs, buffer.index()); buffer.release(); buffer.close(); assertEquals(0, buffer.refCount()); assertTrue(file.delete()); if (System.nanoTime() - start > 1e9) break; } long time = System.nanoTime() - start; System.out.printf("The average time was %,d us%n", time / runs / 1000); } cache.close(); }
@Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } }
VanillaMappedFile implements VanillaMappedResource { @Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } } }
VanillaMappedFile implements VanillaMappedResource { @Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } } VanillaMappedFile(final File path, VanillaMappedMode mode);  VanillaMappedFile(final File path, VanillaMappedMode mode, long size,
                             FileLifecycleListener fileLifecycleListener); }
VanillaMappedFile implements VanillaMappedResource { @Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } } VanillaMappedFile(final File path, VanillaMappedMode mode);  VanillaMappedFile(final File path, VanillaMappedMode mode, long size,
                             FileLifecycleListener fileLifecycleListener); static VanillaMappedFile readWrite(final File path); static VanillaMappedFile readWrite(final File path, long size); static VanillaMappedFile readOnly(final File path); static VanillaMappedFile readOnly(final File path, long size); static VanillaMappedBytes readWriteBytes(final File path, long size); static VanillaMappedBytes readWriteBytes(final File path, long size, long index); static VanillaMappedBytes readWriteBytes(final File path, long size, long index, FileLifecycleListener fileLifecycleListener); VanillaMappedBytes bytes(long address, long size); VanillaMappedBytes bytes(long address, long size, long index); @Override String path(); @Override long size(); @Override synchronized void close(); }
VanillaMappedFile implements VanillaMappedResource { @Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } } VanillaMappedFile(final File path, VanillaMappedMode mode);  VanillaMappedFile(final File path, VanillaMappedMode mode, long size,
                             FileLifecycleListener fileLifecycleListener); static VanillaMappedFile readWrite(final File path); static VanillaMappedFile readWrite(final File path, long size); static VanillaMappedFile readOnly(final File path); static VanillaMappedFile readOnly(final File path, long size); static VanillaMappedBytes readWriteBytes(final File path, long size); static VanillaMappedBytes readWriteBytes(final File path, long size, long index); static VanillaMappedBytes readWriteBytes(final File path, long size, long index, FileLifecycleListener fileLifecycleListener); VanillaMappedBytes bytes(long address, long size); VanillaMappedBytes bytes(long address, long size, long index); @Override String path(); @Override long size(); @Override synchronized void close();  }