本文整理汇总了Java中com.google.ipc.invalidation.util.NamedRunnable类的典型用法代码示例。如果您正苦于以下问题:Java NamedRunnable类的具体用法?Java NamedRunnable怎么用?Java NamedRunnable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NamedRunnable类属于com.google.ipc.invalidation.util包,在下文中一共展示了NamedRunnable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: schedule
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void schedule(int delayMs, Runnable runnable) {
if (!(runnable instanceof NamedRunnable)) {
throw new RuntimeException("Unsupported: can only schedule named runnables, not " + runnable);
}
// Create an intent that will cause the service to run the right recurring task. We explicitly
// target it to our AlarmReceiver so that no other process in the system can receive it and so
// that our AlarmReceiver will not be able to receive events from any other broadcaster (which
// it would be if we used action-based targeting).
String taskName = ((NamedRunnable) runnable).getName();
long executeMs = clock.nowMs() + delayMs;
while (scheduledTasks.containsKey(executeMs)) {
++executeMs;
}
scheduledTasks.put(executeMs, taskName);
ensureIntentScheduledForSoonestTask();
}
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:AndroidInternalScheduler.java
示例2: createRunnable
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
private NamedRunnable createRunnable() {
return new NamedRunnable(name) {
@Override
public void run() {
Preconditions.checkState(scheduler.isRunningOnThread(), "Not on scheduler thread");
isScheduled = false;
if (runTask()) {
// The task asked to be rescheduled, so reschedule it after a timeout has occured.
Preconditions.checkState((delayGenerator != null) || (initialDelayMs != 0),
"Spinning: No exp back off and initialdelay is zero");
ensureScheduled(true, "Retry");
} else if (delayGenerator != null) {
// The task asked not to be rescheduled. Treat it as having "succeeded" and reset the
// delay generator.
delayGenerator.reset();
}
}
};
}
开发者ID:mogoweb,项目名称:365browser,代码行数:20,代码来源:RecurringTask.java
示例3: writeKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void writeKey(final String key, final byte[] value, final Callback<Status> callback) {
// Need to schedule immediately because C++ locks aren't reentrant, and
// C++ locking code assumes that this call will not return directly.
// Schedule the write even if the resources are started since the
// scheduler will prevent it from running in case the resources have been
// stopped.
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.writeKey") {
@Override
public void run() {
ticlPersistentState.put(key, value);
callback.accept(Status.newInstance(Status.Code.SUCCESS, ""));
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:MemoryStorageImpl.java
示例4: readKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void readKey(final String key, final Callback<SimplePair<Status, byte[]>> done) {
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.readKey") {
@Override
public void run() {
byte[] value = TypedUtil.mapGet(ticlPersistentState, key);
final SimplePair<Status, byte[]> result;
if (value != null) {
result = SimplePair.of(Status.newInstance(Status.Code.SUCCESS, ""), value);
} else {
String error = "No value present in map for " + key;
result = SimplePair.of(Status.newInstance(Status.Code.PERMANENT_FAILURE, error), null);
}
done.accept(result);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:MemoryStorageImpl.java
示例5: schedule
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void schedule(int delayMs, Runnable runnable) {
if (!(runnable instanceof NamedRunnable)) {
throw new RuntimeException("Unsupported: can only schedule named runnables, not " + runnable);
}
// Create an intent that will cause the service to run the right recurring task. We explicitly
// target it to our AlarmReceiver so that no other process in the system can receive it and so
// that our AlarmReceiver will not be able to receive events from any other broadcaster (which
// it would be if we used action-based targeting).
String taskName = ((NamedRunnable) runnable).getName();
Intent eventIntent = ProtocolIntents.newSchedulerIntent(taskName, ticlId);
eventIntent.setClass(context, AlarmReceiver.class);
// Create a pending intent that will cause the AlarmManager to fire the above intent.
PendingIntent sender = PendingIntent.getBroadcast(context,
(int) (Integer.MAX_VALUE * Math.random()), eventIntent, PendingIntent.FLAG_ONE_SHOT);
// Schedule the pending intent after the appropriate delay.
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
long executeMs = clock.nowMs() + delayMs;
alarmManager.set(AlarmManager.RTC, executeMs, sender);
}
开发者ID:morristech,项目名称:android-chromium,代码行数:23,代码来源:AndroidInternalScheduler.java
示例6: schedule
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void schedule(final int delayMs, final Runnable runnable) {
// For simplicity, schedule first and then check when the event runs later if the resources
// have been shut down.
scheduler.schedule(new NamedRunnable("AndroidScheduler") {
@Override
public void run() {
if (thread != Thread.currentThread()) {
// Either at initialization or if the thread has been killed or restarted by the
// Executor service.
thread = Thread.currentThread();
thread.setName(threadName);
}
if (systemResources.isStarted()) {
runnable.run();
} else {
systemResources.getLogger().warning("Not running on internal thread since resources " +
"not started %s, %s", delayMs, runnable);
}
}
}, delayMs, TimeUnit.MILLISECONDS);
}
开发者ID:morristech,项目名称:android-chromium,代码行数:24,代码来源:AndroidResourcesFactory.java
示例7: readKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void readKey(final String key, final Callback<SimplePair<Status, byte[]>> done) {
scheduler.execute(new NamedRunnable("AndroidStorage.readKey") {
@Override
public void run() {
byte [] value = properties.get(key);
if (value != null) {
done.accept(SimplePair.of(SUCCESS, value));
} else {
Status status =
Status.newInstance(Status.Code.PERMANENT_FAILURE, "No value in map for " + key);
done.accept(SimplePair.of(status, (byte []) null));
}
}
});
}
开发者ID:morristech,项目名称:android-chromium,代码行数:17,代码来源:AndroidStorage.java
示例8: invalidate
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void invalidate(final InvalidationClient client, final Invalidation invalidation,
final AckHandle ackHandle) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
Preconditions.checkNotNull(ackHandle);
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.invalidate") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INVALIDATE);
delegate.invalidate(client, invalidation, ackHandle);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:14,代码来源:CheckingInvalidationListener.java
示例9: invalidateUnknownVersion
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void invalidateUnknownVersion(final InvalidationClient client, final ObjectId objectId,
final AckHandle ackHandle) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
Preconditions.checkNotNull(ackHandle);
listenerScheduler.schedule(NO_DELAY,
new NamedRunnable("CheckingInvalListener.invalidateUnknownVersion") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INVALIDATE_UNKNOWN);
delegate.invalidateUnknownVersion(client, objectId, ackHandle);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:CheckingInvalidationListener.java
示例10: invalidateAll
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void invalidateAll(final InvalidationClient client, final AckHandle ackHandle) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
Preconditions.checkNotNull(ackHandle);
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.invalidateAll") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INVALIDATE_ALL);
delegate.invalidateAll(client, ackHandle);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:CheckingInvalidationListener.java
示例11: informRegistrationFailure
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void informRegistrationFailure(final InvalidationClient client, final ObjectId objectId,
final boolean isTransient, final String errorMessage) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.regFailure") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INFORM_REGISTRATION_FAILURE);
delegate.informRegistrationFailure(client, objectId, isTransient, errorMessage);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:CheckingInvalidationListener.java
示例12: informRegistrationStatus
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void informRegistrationStatus(final InvalidationClient client, final ObjectId objectId,
final RegistrationState regState) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.regStatus") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INFORM_REGISTRATION_STATUS);
delegate.informRegistrationStatus(client, objectId, regState);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:CheckingInvalidationListener.java
示例13: reissueRegistrations
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void reissueRegistrations(final InvalidationClient client, final byte[] prefix,
final int prefixLen) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.reissueRegs") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.REISSUE_REGISTRATIONS);
delegate.reissueRegistrations(client, prefix, prefixLen);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:CheckingInvalidationListener.java
示例14: informError
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void informError(final InvalidationClient client, final ErrorInfo errorInfo) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.informError") {
@Override
public void run() {
statistics.recordListenerEvent(ListenerEventType.INFORM_ERROR);
delegate.informError(client, errorInfo);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:CheckingInvalidationListener.java
示例15: ready
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void ready(final InvalidationClient client) {
Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread");
listenerScheduler.schedule(NO_DELAY, new NamedRunnable("CheckingInvalListener.ready") {
@Override
public void run() {
logger.info("Informing app that ticl is ready");
delegate.ready(client);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:CheckingInvalidationListener.java
示例16: writeKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void writeKey(String key, byte[] value, final Callback<Status> done) {
delegate.writeKey(key, value, new Callback<Status>() {
@Override
public void accept(final Status status) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.writeKey") {
@Override
public void run() {
done.accept(status);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例17: readKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void readKey(String key, final Callback<SimplePair<Status, byte[]>> done) {
delegate.readKey(key, new Callback<SimplePair<Status, byte[]>>() {
@Override
public void accept(final SimplePair<Status, byte[]> result) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.readKey") {
@Override
public void run() {
done.accept(result);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例18: deleteKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void deleteKey(String key, final Callback<Boolean> done) {
delegate.deleteKey(key, new Callback<Boolean>() {
@Override
public void accept(final Boolean success) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.deleteKey") {
@Override
public void run() {
done.accept(success);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例19: readAllKeys
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void readAllKeys(final Callback<SimplePair<Status, String>> keyCallback) {
delegate.readAllKeys(new Callback<SimplePair<Status, String>>() {
@Override
public void accept(final SimplePair<Status, String> keyResult) {
scheduler.schedule(NO_DELAY, new NamedRunnable("SafeStorage.readAllKeys") {
@Override
public void run() {
keyCallback.accept(keyResult);
}
});
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:SafeStorage.java
示例20: deleteKey
import com.google.ipc.invalidation.util.NamedRunnable; //导入依赖的package包/类
@Override
public void deleteKey(final String key, final Callback<Boolean> done) {
scheduler.schedule(Scheduler.NO_DELAY,
new NamedRunnable("MemoryStorage.deleteKey") {
@Override
public void run() {
TypedUtil.remove(ticlPersistentState, key);
done.accept(true);
}
});
}
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:MemoryStorageImpl.java
注:本文中的com.google.ipc.invalidation.util.NamedRunnable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论