X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fro%2Fieval%2Ffonbot%2FExecutableRunnable.java;h=4011338c4d2e9de175c50b3e1b3590f1e37a9db3;hb=5b5c357e7016b028883e03f7a38f0efd9bbfb7b9;hp=13addac0a5a9e7bd238fcecc68189591f396b67f;hpb=e154bdfd76071b99635317ef8c7ab11918b88794;p=fonbot.git
diff --git a/src/ro/ieval/fonbot/ExecutableRunnable.java b/src/ro/ieval/fonbot/ExecutableRunnable.java
index 13addac..4011338 100644
--- a/src/ro/ieval/fonbot/ExecutableRunnable.java
+++ b/src/ro/ieval/fonbot/ExecutableRunnable.java
@@ -41,33 +41,33 @@ import android.os.SystemClock;
*/
abstract class ExecutableRunnable implements Runnable {
/** Executor used to execute instances of this class */
- private static final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
+ private static final ScheduledExecutorService EXECUTORS = Executors.newSingleThreadScheduledExecutor();
/** Queue containing ExecutableRunnable
s that should be retried */
- private static final Queue retryPendingTasks = new LinkedList();
+ private static final Queue RETRY_PENDING_TASKS = new LinkedList();
/** Minimum interval between task retries, in milliseconds */
- private static final long retryInterval = 30000;
+ private static final long RETRY_INTERVAL = 30000;
/** {@link SystemClock#elapsedRealtime()} time of last successful call to {@link #retryTasks()} */
private static long lastRetry = 0;
- /** True if a retryTasks run is already scheduled on {@link #executor} */
+ /** True if a retryTasks run is already scheduled on {@link #EXECUTORS} */
private static volatile boolean retryIsScheduled = false;
/** Run all tasks that should be retried */
public static final void retryTasks(){
- if(!retryIsScheduled && lastRetry+retryInterval>SystemClock.elapsedRealtime()){
+ if(!retryIsScheduled && lastRetry+RETRY_INTERVAL>SystemClock.elapsedRealtime()){
retryIsScheduled = true;
- executor.schedule(new Runnable() {
+ EXECUTORS.schedule(new Runnable() {
@Override
public void run() {
retryTasks();
retryIsScheduled = false;
}
- }, retryInterval, TimeUnit.MILLISECONDS);
+ }, RETRY_INTERVAL, TimeUnit.MILLISECONDS);
return;
}
- synchronized(retryPendingTasks){
- for(ExecutableRunnable task : retryPendingTasks)
- executor.execute(task);
- retryPendingTasks.clear();
+ synchronized(RETRY_PENDING_TASKS){
+ for(ExecutableRunnable task : RETRY_PENDING_TASKS)
+ EXECUTORS.execute(task);
+ RETRY_PENDING_TASKS.clear();
}
lastRetry=SystemClock.elapsedRealtime();
}
@@ -75,13 +75,13 @@ abstract class ExecutableRunnable implements Runnable {
/** Execute this ExecutableRunnable
*/
public final void execute(){
retryTasks();
- executor.execute(this);
+ EXECUTORS.execute(this);
}
/** Mark this ExecutableRunnable
as needing to be retried later */
protected final void retry(){
- synchronized(retryPendingTasks){
- retryPendingTasks.add(this);
+ synchronized(RETRY_PENDING_TASKS){
+ RETRY_PENDING_TASKS.add(this);
}
}
}