Allow multiple AsyncTasks to run concurrently

Fixes #134
This commit is contained in:
2016-09-03 09:00:20 -04:00
parent f178bcbdd2
commit 8eb9f398d5
4 changed files with 6 additions and 4 deletions

View File

@@ -179,7 +179,7 @@ public abstract class CheckmarkList
* @param from timestamp for the beginning of the interval
* @param to timestamp for the end of the interval
*/
protected final void compute(long from, final long to)
protected final synchronized void compute(long from, final long to)
{
final long day = DateUtils.millisecondsInOneDay;

View File

@@ -154,7 +154,7 @@ public abstract class ScoreList implements Iterable<Score>
* @param from timestamp of the beginning of the interval
* @param to timestamp of the end of the time interval
*/
protected void compute(long from, long to)
protected synchronized void compute(long from, long to)
{
final long day = DateUtils.millisecondsInOneDay;
final double freq = habit.getFrequency().toDouble();

View File

@@ -65,7 +65,7 @@ public abstract class StreakList
public abstract void invalidateNewerThan(long timestamp);
public void rebuild()
public synchronized void rebuild()
{
long today = DateUtils.getStartOfToday();

View File

@@ -27,6 +27,8 @@ import java.util.*;
import dagger.*;
import static android.os.AsyncTask.*;
@Module
public class AndroidTaskRunner implements TaskRunner
{
@@ -60,7 +62,7 @@ public class AndroidTaskRunner implements TaskRunner
public void execute(Task task)
{
task.onAttached(this);
new CustomAsyncTask(task).execute();
new CustomAsyncTask(task).executeOnExecutor(THREAD_POOL_EXECUTOR);
}
@Override