File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/main/java/com/reactnativecommunity/asyncstorage Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ if( newDbSize != null && newDbSize.isLong()) {
30
30
dbSizeInMB = newDbSize. toLong()
31
31
}
32
32
33
+ def useCustomExecutor = rootProject. hasProperty(' AsyncStorage_useCustomExecutor' )
34
+ ? rootProject. properties[' AsyncStorage_useCustomExecutor' ]
35
+ : false
36
+
33
37
apply plugin : ' com.android.library'
34
38
35
39
android {
@@ -41,6 +45,7 @@ android {
41
45
targetSdkVersion getExtOrIntegerDefault(' targetSdkVersion' )
42
46
43
47
buildConfigField " Long" , " AsyncStorage_db_size" , " ${ dbSizeInMB} L"
48
+ buildConfigField(" boolean" , " AsyncStorage_useCustomExecutor" , " ${ useCustomExecutor} " )
44
49
}
45
50
}
46
51
Original file line number Diff line number Diff line change 29
29
import java .util .ArrayDeque ;
30
30
import java .util .HashSet ;
31
31
import java .util .concurrent .Executor ;
32
+ import java .util .concurrent .Executors ;
32
33
33
34
@ ReactModule (name = AsyncStorageModule .NAME )
34
35
public final class AsyncStorageModule
@@ -78,7 +79,12 @@ synchronized void scheduleNext() {
78
79
private final SerialExecutor executor ;
79
80
80
81
public AsyncStorageModule (ReactApplicationContext reactContext ) {
81
- this (reactContext , AsyncTask .THREAD_POOL_EXECUTOR );
82
+ this (
83
+ reactContext ,
84
+ BuildConfig .AsyncStorage_useCustomExecutor
85
+ ? Executors .newSingleThreadExecutor ()
86
+ : AsyncTask .THREAD_POOL_EXECUTOR
87
+ );
82
88
}
83
89
84
90
@ VisibleForTesting
You can’t perform that action at this time.
0 commit comments