当前位置: 首页>>代码示例>>Java>>正文


Java GcFinalization.awaitDone方法代码示例

本文整理汇总了Java中com.google.common.testing.GcFinalization.awaitDone方法的典型用法代码示例。如果您正苦于以下问题:Java GcFinalization.awaitDone方法的具体用法?Java GcFinalization.awaitDone怎么用?Java GcFinalization.awaitDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.testing.GcFinalization的用法示例。


在下文中一共展示了GcFinalization.awaitDone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFinalizeDeletesFile

import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeDeletesFile() throws Exception {
  byte[] data = newPreFilledByteArray(100);
  FileBackedOutputStream out = new FileBackedOutputStream(0, true);

  write(out, data, 0, 100, true);
  final File file = out.getFile();
  assertEquals(100, file.length());
  assertTrue(file.exists());
  out.close();

  // Make sure that finalize deletes the file
  out = null;

  // times out and throws RuntimeException on failure
  GcFinalization.awaitDone(new GcFinalization.FinalizationPredicate() {
    @Override
    public boolean isDone() {
      return !file.exists();
    }
  });
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:FileBackedOutputStreamTest.java

示例2: testFinalizeDeletesFile

import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeDeletesFile() throws Exception {
  byte[] data = newPreFilledByteArray(100);
  FileBackedOutputStream out = new FileBackedOutputStream(0, true);

  write(out, data, 0, 100, true);
  final File file = out.getFile();
  assertEquals(100, file.length());
  assertTrue(file.exists());
  out.close();

  // Make sure that finalize deletes the file
  out = null;

  // times out and throws RuntimeException on failure
  GcFinalization.awaitDone(
      new GcFinalization.FinalizationPredicate() {
        @Override
        public boolean isDone() {
          return !file.exists();
        }
      });
}
 
开发者ID:google,项目名称:guava,代码行数:23,代码来源:FileBackedOutputStreamTest.java

示例3: testFinalizeReferentCalled

import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeReferentCalled() {
  final MockReference reference = new MockReference(
      frq = new FinalizableReferenceQueue());

  GcFinalization.awaitDone(new GcFinalization.FinalizationPredicate() {
      public boolean isDone() {
        return reference.finalizeReferentCalled;
      }
    });
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:FinalizableReferenceQueueTest.java

示例4: garbageCollect

import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
private void garbageCollect(int expectedSize) {
    GcFinalization.awaitDone(new FinalizationPredicate() {
        @Override
        public boolean isDone() {
            store.cleanUp();
            return store.size() == expectedSize;
        }
    });
}
 
开发者ID:anonl,项目名称:nvlist,代码行数:10,代码来源:GeneratedResourceStoreTest.java

示例5: testFinalizeReferentCalled

import com.google.common.testing.GcFinalization; //导入方法依赖的package包/类
public void testFinalizeReferentCalled() {
  final MockReference reference = new MockReference(frq = new FinalizableReferenceQueue());

  GcFinalization.awaitDone(
      new GcFinalization.FinalizationPredicate() {
        public boolean isDone() {
          return reference.finalizeReferentCalled;
        }
      });
}
 
开发者ID:google,项目名称:guava,代码行数:11,代码来源:FinalizableReferenceQueueTest.java


注:本文中的com.google.common.testing.GcFinalization.awaitDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。