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


Java Util.threadFactory方法代码示例

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


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

示例1: initReaderAndWriter

import okhttp3.internal.Util; //导入方法依赖的package包/类
public void initReaderAndWriter(
    String name, long pingIntervalMillis, Streams streams) throws IOException {
  synchronized (this) {
    this.streams = streams;
    this.writer = new WebSocketWriter(streams.client, streams.sink, random);
    this.executor = new ScheduledThreadPoolExecutor(1, Util.threadFactory(name, false));
    if (pingIntervalMillis != 0) {
      executor.scheduleAtFixedRate(
          new PingRunnable(), pingIntervalMillis, pingIntervalMillis, MILLISECONDS);
    }
    if (!messageAndCloseQueue.isEmpty()) {
      runWriter(); // Send messages that were enqueued before we were connected.
    }
  }

  reader = new WebSocketReader(streams.client, streams.source, this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:RealWebSocket.java

示例2: create

import okhttp3.internal.Util; //导入方法依赖的package包/类
/**
 * Create a cache which will reside in {@code directory}. This cache is lazily initialized on
 * first access and will be created if it does not exist.
 *
 * @param directory a writable directory
 * @param valueCount the number of values per cache entry. Must be positive.
 * @param maxSize the maximum number of bytes this cache should use to store
 */
public static DiskLruCache create(FileSystem fileSystem, File directory, int appVersion,
    int valueCount, long maxSize) {
  if (maxSize <= 0) {
    throw new IllegalArgumentException("maxSize <= 0");
  }
  if (valueCount <= 0) {
    throw new IllegalArgumentException("valueCount <= 0");
  }

  // Use a single background thread to evict entries.
  Executor executor = new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS,
      new LinkedBlockingQueue<Runnable>(), Util.threadFactory("OkHttp DiskLruCache", true));

  return new DiskLruCache(fileSystem, directory, appVersion, valueCount, maxSize, executor);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:DiskLruCache.java

示例3: Http2Connection

import okhttp3.internal.Util; //导入方法依赖的package包/类
Http2Connection(Builder builder) {
  pushObserver = builder.pushObserver;
  client = builder.client;
  listener = builder.listener;
  // http://tools.ietf.org/html/draft-ietf-httpbis-http2-17#section-5.1.1
  nextStreamId = builder.client ? 1 : 2;
  if (builder.client) {
    nextStreamId += 2; // In HTTP/2, 1 on client is reserved for Upgrade.
  }

  nextPingId = builder.client ? 1 : 2;

  // Flow control was designed more for servers, or proxies than edge clients.
  // If we are a client, set the flow control window to 16MiB.  This avoids
  // thrashing window updates every 64KiB, yet small enough to avoid blowing
  // up the heap.
  if (builder.client) {
    okHttpSettings.set(Settings.INITIAL_WINDOW_SIZE, OKHTTP_CLIENT_WINDOW_SIZE);
  }

  hostname = builder.hostname;

  // Like newSingleThreadExecutor, except lazy creates the thread.
  pushExecutor = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS,
      new LinkedBlockingQueue<Runnable>(),
      Util.threadFactory(Util.format("OkHttp %s Push Observer", hostname), true));
  peerSettings.set(Settings.INITIAL_WINDOW_SIZE, DEFAULT_INITIAL_WINDOW_SIZE);
  peerSettings.set(Settings.MAX_FRAME_SIZE, Http2.INITIAL_MAX_FRAME_SIZE);
  bytesLeftInWriteWindow = peerSettings.getInitialWindowSize();
  socket = builder.socket;
  writer = new Http2Writer(builder.sink, client);

  readerRunnable = new ReaderRunnable(new Http2Reader(builder.source, client));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:Http2Connection.java


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