本文整理汇总了Java中com.google.ipc.invalidation.external.client.SystemResources.Scheduler方法的典型用法代码示例。如果您正苦于以下问题:Java SystemResources.Scheduler方法的具体用法?Java SystemResources.Scheduler怎么用?Java SystemResources.Scheduler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.ipc.invalidation.external.client.SystemResources
的用法示例。
在下文中一共展示了SystemResources.Scheduler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retryUntilSuccessWithBackoff
import com.google.ipc.invalidation.external.client.SystemResources; //导入方法依赖的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);
}
});
}
});
}
示例2: getInternalSchedulerForTest
import com.google.ipc.invalidation.external.client.SystemResources; //导入方法依赖的package包/类
/** Returns the client internal scheduler */
SystemResources.Scheduler getInternalSchedulerForTest();