gpt4 book ai didi

org.geotools.util.WeakCollectionCleaner类的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 10:59:05 27 4
gpt4 key购买 nike

本文整理了Java中org.geotools.util.WeakCollectionCleaner类的一些代码示例,展示了WeakCollectionCleaner类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeakCollectionCleaner类的具体详情如下:
包路径:org.geotools.util.WeakCollectionCleaner
类名称:WeakCollectionCleaner

WeakCollectionCleaner介绍

[英]A thread invoking Reference#clear on each enqueded reference. This is usefull only if Reference subclasses has overridden their clear() method in order to perform some cleaning. This thread is used by WeakHashSet and WeakValueHashMap, which remove their entry from the collection when Reference#clear is invoked.
[中]调用引用的线程#在每个被赋予的引用上清除。只有当引用子类为了执行某些清理而重写了clear()方法时,这才有用。WeakHashSet和WeakValueHashMap使用该线程,当调用引用#clear时,它们会从集合中删除它们的条目。

代码示例

代码示例来源:origin: geotools/geotools

public BufferSoftReference(ByteBuffer referent) {
  super(referent, WeakCollectionCleaner.DEFAULT.getReferenceQueue());
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Hook to cleanup various stuff of some used libraries (org.geotools), which depend on the
 * external client to call them for cleaning-up.
 */
private void cleanupWebapp() {
  LOG.info("Web application shutdown: cleaning various stuff");
  WeakCollectionCleaner.DEFAULT.exit();
  DeferredAuthorityFactory.exit();
}

代码示例来源:origin: geotools/geotools

/**
   * Stops the cleaner thread. Calling this method is recommended in all long running applications
   * with custom class loaders (e.g., web applications).
   */
  public void exit() {
    // try to stop it gracefully
    synchronized (this) {
      referenceQueue = null;
    }
    this.interrupt();
    try {
      this.join(500);
    } catch (InterruptedException e) {

    }
    // last resort tentative to kill the cleaner thread
    if (this.isAlive()) this.stop();
  }
}

代码示例来源:origin: geotools/geotools

/**
 * Constructs and starts a new thread as a daemon. This thread will be sleeping most of the
 * time. It will run only some few nanoseconds each time a new {@link Reference} is enqueded.
 */
private WeakCollectionCleaner() {
  super("WeakCollectionCleaner");
  setPriority(MAX_PRIORITY - 2);
  setDaemon(true);
  start();
}

代码示例来源:origin: geotools/geotools

public void run() {
  ReferenceQueue<Object> rq;
  while ((rq = getReferenceQueue()) != null) {
    try {
        sleep(15 * 1000L);
        break;

代码示例来源:origin: geotools/geotools

/**
 * Returns the value to which this map maps the specified key. Returns {@code null} if the map
 * contains no mapping for this key.
 *
 * @param key Key whose associated value is to be returned.
 * @return The value to which this map maps the specified key.
 * @throws NullPointerException if the key is {@code null}.
 */
@Override
public synchronized V get(final Object key) {
  assert WeakCollectionCleaner.DEFAULT.isAlive();
  assert valid() : count;
  final int index = (key.hashCode() & 0x7FFFFFFF) % table.length;
  for (Entry e = table[index]; e != null; e = e.next) {
    if (key.equals(e.key)) {
      return e.get();
    }
  }
  return null;
}

代码示例来源:origin: org.geotools/gt2-metadata

sleep(15 * 1000L);
break;

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Constructs and starts a new thread as a daemon. This thread will be sleeping
 * most of the time.  It will run only some few nanoseconds each time a new
 * {@link WeakReference} is enqueded.
 */
private WeakCollectionCleaner() {
  super("WeakCollectionCleaner");
  setPriority(MAX_PRIORITY - 2);
  setDaemon(true);
  start();
}

代码示例来源:origin: org.geotools/gt-metadata

public void run() {
  ReferenceQueue<Object> rq;
  while ((rq = getReferenceQueue ()) != null) {
    try {
        sleep(15 * 1000L);
        break;

代码示例来源:origin: geotools/geotools

final <T extends E> T intern(final T obj, final int operation) {
  assert Thread.holdsLock(this);
  assert WeakCollectionCleaner.DEFAULT.isAlive();
  assert valid() : count;
  if (obj != null) {

代码示例来源:origin: geotools/geotools

public DataStoreSoftReference(DataStore referent) {
  super(referent, WeakCollectionCleaner.DEFAULT.getReferenceQueue());
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Constructs and starts a new thread as a daemon. This thread will be sleeping
 * most of the time.  It will run only some few nanoseconds each time a new
 * {@link Reference} is enqueded.
 */
private WeakCollectionCleaner() {
  super("WeakCollectionCleaner");
  setPriority(MAX_PRIORITY - 2);
  setDaemon(true);
  start();
}

代码示例来源:origin: org.geotools/gt-metadata

/**
   * Stops the cleaner thread. Calling this method is recommended in all long running applications
   * with custom class loaders (e.g., web applications).
   */
  public void exit() {
    // try to stop it gracefully
    synchronized (this) {
      referenceQueue = null;
    }
    this.interrupt();
    try {
      this.join(500);
    } catch (InterruptedException e) {

    }
    // last resort tentative to kill the cleaner thread
    if (this.isAlive())
      this.stop();
  }
}

代码示例来源:origin: geotools/geotools

/** Implementation of {@link #put} and {@link #remove} operations. */
private synchronized V intern(final K key, final V value) {
  assert WeakCollectionCleaner.DEFAULT.isAlive();
  assert valid() : count;
  /*
   * Check if {@code obj} is already contained in this
   * {@code WeakValueHashMap}. If yes, clear it.
   */
  V oldValue = null;
  final int hash = key.hashCode() & 0x7FFFFFFF;
  int index = hash % table.length;
  for (Entry e = table[index]; e != null; e = e.next) {
    if (key.equals(e.key)) {
      oldValue = e.get();
      e.clear();
    }
  }
  if (value != null) {
    if (count >= threshold) {
      rehash(true);
    }
    index = hash % table.length;
    table[index] = new Entry(key, value, table[index], index);
    count++;
  }
  assert valid();
  return oldValue;
}

代码示例来源:origin: geoserver/geoserver

WeakCollectionCleaner.DEFAULT.exit();
DeferredAuthorityFactory.exit();
CRS.reset("all");

代码示例来源:origin: org.geotools/gt-data

public DataStoreSoftReference(DataStore referent) {
  super(referent, WeakCollectionCleaner.DEFAULT.getReferenceQueue());
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Returns the value to which this map maps the specified key. Returns
 * {@code null} if the map contains no mapping for this key.
 *
 * @param  key Key whose associated value is to be returned.
 * @return The value to which this map maps the specified key.
 * @throws NullPointerException if the key is {@code null}.
 */
@Override
public synchronized V get(final Object key) {
  assert WeakCollectionCleaner.DEFAULT.isAlive();
  assert valid() : count;
  final int index = (key.hashCode() & 0x7FFFFFFF) % table.length;
  for (Entry e=table[index]; e!=null; e=e.next) {
    if (key.equals(e.key)) {
      return e.get();
    }
  }
  return null;
}

代码示例来源:origin: org.geotools/gt-metadata

public BufferSoftReference(ByteBuffer referent) {
  super(referent, WeakCollectionCleaner.DEFAULT.getReferenceQueue());
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Returns the value to which this map maps the specified key. Returns
 * {@code null} if the map contains no mapping for this key.
 *
 * @param  key Key whose associated value is to be returned.
 * @return The value to which this map maps the specified key.
 * @throws NullPointerException if the key is {@code null}.
 */
public synchronized Object get(final Object key) {
  assert WeakCollectionCleaner.DEFAULT.isAlive();
  assert valid() : count;
  final int index = (key.hashCode() & 0x7FFFFFFF) % table.length;
  for (Entry e=table[index]; e!=null; e=e.next) {
    if (key.equals(e.key)) {
      return e.get();
    }
  }
  return null;
}

代码示例来源:origin: org.geotools/gt-directory

public DataStoreSoftReference(DataStore referent) {
  super(referent, WeakCollectionCleaner.DEFAULT.getReferenceQueue());
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com