本文整理汇总了Java中com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator类的典型用法代码示例。如果您正苦于以下问题:Java ExponentialBackoffDelayGenerator类的具体用法?Java ExponentialBackoffDelayGenerator怎么用?Java ExponentialBackoffDelayGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExponentialBackoffDelayGenerator类属于com.google.ipc.invalidation.util包,在下文中一共展示了ExponentialBackoffDelayGenerator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: retryUntilSuccessWithBackoff
import com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator; //导入依赖的package包/类
/**
* A utility function to run an async runnable with exponential backoff after failures.
* @param runnable the asynchronous runnable.
* @param scheduler used to schedule retries.
* @param backOffGenerator a backoff generator that returns how to long to wait between retries.
* The client must pass a new instance or reset the backoff generator before calling this
* method.
*/
static void retryUntilSuccessWithBackoff(final SystemResources.Scheduler scheduler,
final ExponentialBackoffDelayGenerator backOffGenerator, final AsyncRunnable runnable) {
logger.fine("Running %s", runnable);
runnable.run(new CompletionCallback() {
@Override
public void success() {
logger.fine("%s succeeded", runnable);
}
@Override
public void failure() {
int nextDelay = backOffGenerator.getNextDelay();
logger.fine("%s failed, retrying after %s ms", nextDelay);
scheduler.schedule(nextDelay, new Runnable() {
@Override
public void run() {
retryUntilSuccessWithBackoff(scheduler, backOffGenerator, runnable);
}
});
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:32,代码来源:AndroidChannel.java
示例2: setSystemResources
import com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator; //导入依赖的package包/类
@Override
public void setSystemResources(SystemResources resources) {
this.resources = resources;
// Prefetch the auth sub token. Since this might require an HTTP round trip, we do this
// as soon as the resources are available.
// TODO: Find a better place to fetch the auth token; this method
// doesn't sound like one that should be doing work.
retryUntilSuccessWithBackoff(resources.getInternalScheduler(),
new ExponentialBackoffDelayGenerator(
new Random(), INITIAL_AUTH_TOKEN_RETRY_DELAY_MS, MAX_AUTH_TOKEN_RETRY_FACTOR),
new AsyncRunnable() {
@Override
public void run(CompletionCallback callback) {
requestAuthToken(callback);
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:19,代码来源:AndroidChannel.java
示例3: getDelayGenerator
import com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator; //导入依赖的package包/类
/** Returns the delay generator, if any. */
ExponentialBackoffDelayGenerator getDelayGenerator() {
return delayGenerator;
}
开发者ID:mogoweb,项目名称:365browser,代码行数:5,代码来源:RecurringTask.java
注:本文中的com.google.ipc.invalidation.util.ExponentialBackoffDelayGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论