Added fetch yield

This commit is contained in:
M66B 2020-11-10 20:06:02 +01:00
parent ab224f1103
commit 3cbba021e5
1 changed files with 7 additions and 0 deletions

View File

@ -119,6 +119,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private static final int ACCOUNT_ERROR_AFTER_POLL = 4; // times
private static final int BACKOFF_ERROR_AFTER = 16; // seconds
private static final int FAST_FAIL_THRESHOLD = 75; // percent
private static final int FETCH_YIELD_DURATION = 50; // milliseconds
private static final String ACTION_NEW_MESSAGE_COUNT = BuildConfig.APPLICATION_ID + ".NEW_MESSAGE_COUNT";
@ -1175,6 +1176,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} finally {
db.endTransaction();
}
Thread.sleep(FETCH_YIELD_DURATION);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
@ -1204,6 +1207,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} finally {
db.endTransaction();
}
Thread.sleep(FETCH_YIELD_DURATION);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
@ -1228,6 +1233,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
long uid = ifolder.getUID(e.getMessage());
EntityOperation.queue(ServiceSynchronize.this, folder, EntityOperation.FETCH, uid);
Thread.sleep(FETCH_YIELD_DURATION);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(