okio.Timeout.waitUntilNotified()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(116)

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

Timeout.waitUntilNotified介绍

暂无

代码示例

代码示例来源:origin: square/okhttp

/** Waits for an OAuth session for this client to be set. */
public synchronized void awaitAccessToken(Timeout timeout) throws InterruptedIOException {
 while (session == null) {
  timeout.waitUntilNotified(this);
 }
}

代码示例来源:origin: line/armeria

@Override
public long read(Buffer sink, long byteCount) throws IOException {
  synchronized (buffer) {
    if (sourceClosed) {
      throw new IllegalStateException("closed");
    }
    while (buffer.size() == 0) {
      if (sinkClosed) {
        if (sinkClosedException == null) {
          return -1L;
        }
        throw new IOException(sinkClosedException);
      }
      timeout.waitUntilNotified(buffer);
    }
    final long result = buffer.read(sink, byteCount);
    buffer.notifyAll();
    return result;
  }
}

代码示例来源:origin: square/okhttp

timeout.waitUntilNotified(Relay.this);
continue;

代码示例来源:origin: square/okio

@Test public synchronized void notified() throws InterruptedIOException {
 Timeout timeout = new Timeout();
 timeout.timeout(5000, TimeUnit.MILLISECONDS);
 double start = now();
 executorService.schedule(new Runnable() {
  @Override public void run() {
   synchronized (WaitUntilNotifiedTest.this) {
    WaitUntilNotifiedTest.this.notify();
   }
  }
 }, 1000, TimeUnit.MILLISECONDS);
 timeout.waitUntilNotified(this);
 assertElapsed(1000.0, start);
}

代码示例来源:origin: square/okio

@Test public synchronized void threadInterrupted() {
 Timeout timeout = new Timeout();
 double start = now();
 Thread.currentThread().interrupt();
 try {
  timeout.waitUntilNotified(this);
  fail();
 } catch (InterruptedIOException expected) {
  assertEquals("interrupted", expected.getMessage());
  assertTrue(Thread.interrupted());
 }
 assertElapsed(0.0, start);
}

代码示例来源:origin: com.squareup.okhttp3/okhttp

timeout.waitUntilNotified(Relay.this);
continue;

代码示例来源:origin: square/okio

@Test public synchronized void deadlineAlreadyReached() {
 Timeout timeout = new Timeout();
 timeout.deadlineNanoTime(System.nanoTime());
 double start = now();
 try {
  timeout.waitUntilNotified(this);
  fail();
 } catch (InterruptedIOException expected) {
  assertEquals("timeout", expected.getMessage());
 }
 assertElapsed(0.0, start);
}

代码示例来源:origin: square/okio

@Test public synchronized void timeout() {
 Timeout timeout = new Timeout();
 timeout.timeout(1000, TimeUnit.MILLISECONDS);
 double start = now();
 try {
  timeout.waitUntilNotified(this);
  fail();
 } catch (InterruptedIOException expected) {
  assertEquals("timeout", expected.getMessage());
 }
 assertElapsed(1000.0, start);
}

代码示例来源:origin: square/okio

@Test public synchronized void deadline() {
 Timeout timeout = new Timeout();
 timeout.deadline(1000, TimeUnit.MILLISECONDS);
 double start = now();
 try {
  timeout.waitUntilNotified(this);
  fail();
 } catch (InterruptedIOException expected) {
  assertEquals("timeout", expected.getMessage());
 }
 assertElapsed(1000.0, start);
}

代码示例来源:origin: square/okio

@Test public synchronized void deadlineBeforeTimeout() {
 Timeout timeout = new Timeout();
 timeout.timeout(5000, TimeUnit.MILLISECONDS);
 timeout.deadline(1000, TimeUnit.MILLISECONDS);
 double start = now();
 try {
  timeout.waitUntilNotified(this);
  fail();
 } catch (InterruptedIOException expected) {
  assertEquals("timeout", expected.getMessage());
 }
 assertElapsed(1000.0, start);
}

代码示例来源:origin: square/okio

@Test public synchronized void timeoutBeforeDeadline() {
 Timeout timeout = new Timeout();
 timeout.timeout(1000, TimeUnit.MILLISECONDS);
 timeout.deadline(5000, TimeUnit.MILLISECONDS);
 double start = now();
 try {
  timeout.waitUntilNotified(this);
  fail();
 } catch (InterruptedIOException expected) {
  assertEquals("timeout", expected.getMessage());
 }
 assertElapsed(1000.0, start);
}

代码示例来源:origin: com.github.ljun20160606/okhttp

timeout.waitUntilNotified(Relay.this);
continue;

代码示例来源:origin: apache/servicemix-bundles

timeout.waitUntilNotified(Relay.this);
continue;

相关文章