Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## X.X.X
* Added a new config flag `setUseSerialExecutor(boolean useSerial)` for selecting immediate request executor type.
* Immediate requests now will be run by parallel executor instead of serial by default.

## 25.4.4
* Improved disk size calculation in crash reports.

Expand Down
6 changes: 6 additions & 0 deletions sdk/src/main/java/ly/count/android/sdk/Countly.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ private static class SingletonHolder {

protected CountlyConfig config_ = null;

// for executor choice of immediate requests
boolean useSerialExecutorInternal = false;

//fields for tracking push token debounce
final static long lastRegistrationCallDebounceDuration = 60 * 1000;//60seconds
long lastRegistrationCallTs = 0;
Expand Down Expand Up @@ -369,6 +372,9 @@ public synchronized Countly init(CountlyConfig config) {
config.sdkInternalLimits.maxKeyLength = maxKeyLengthDefault;
}

// should be here for sbs and hc
useSerialExecutorInternal = config.useSerialExecutor;

if (config.sdkInternalLimits.maxValueSize != null) {
if (config.sdkInternalLimits.maxValueSize < 1) {
config.sdkInternalLimits.maxValueSize = 1;
Expand Down
16 changes: 16 additions & 0 deletions sdk/src/main/java/ly/count/android/sdk/CountlyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public class CountlyConfig {
boolean sdkBehaviorSettingsRequestsDisabled = false;
int requestTimeoutDuration = 30; // in seconds

// If set to true, immediate requests will use serial AsyncTask executor instead of the thread pool
boolean useSerialExecutor = false;

/**
* THIS VARIABLE SHOULD NOT BE USED
* IT IS ONLY FOR INTERNAL TESTING
Expand Down Expand Up @@ -1052,6 +1055,19 @@ public synchronized CountlyConfig setRequestTimeoutDuration(int requestTimeoutDu
return this;
}

/**
* To select the legacy AsyncTask.execute (serial executor) or
* instead executeOnExecutor(THREAD_POOL_EXECUTOR)
* Default is false and the SDK will use the thread pool executor.
*
* @param useSerial set to true to use serial executor
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setUseSerialExecutor(boolean useSerial) {
this.useSerialExecutor = useSerial;
return this;
}

/**
* APM configuration interface to be used with CountlyConfig
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public void doWork(@NonNull String requestData, @Nullable String customEndpoint,
assert cp != null;
assert log != null;
assert callback != null;

this.execute(requestData, customEndpoint, cp, requestShouldBeDelayed, networkingIsEnabled, callback, log);
if (Countly.sharedInstance().useSerialExecutorInternal) {
log.d("[ImmediateRequestMaker] Using serial executor");
this.execute(requestData, customEndpoint, cp, requestShouldBeDelayed, networkingIsEnabled, callback, log);
} else {
log.d("[ImmediateRequestMaker] Using parallel executor");
this.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requestData, customEndpoint, cp, requestShouldBeDelayed, networkingIsEnabled, callback, log);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public void doWork(@NonNull String requestData, @Nullable String customEndpoint,
assert cp != null;
assert log != null;
assert callback != null;

this.execute(requestData, customEndpoint, cp, requestShouldBeDelayed, networkingIsEnabled, callback, log);
if (Countly.sharedInstance().useSerialExecutorInternal) {
log.d("[PreflightRequestMaker] Using serial executor");
this.execute(requestData, customEndpoint, cp, requestShouldBeDelayed, networkingIsEnabled, callback, log);
} else {
log.d("[PreflightRequestMaker] Using parallel executor");
this.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, requestData, customEndpoint, cp, requestShouldBeDelayed, networkingIsEnabled, callback, log);
}
}

/**
Expand Down
Loading