Skip to content

Commit 725e73a

Browse files
author
Hideki Itakura
committed
Merge branch 'feature/issue_343_executor_thread_pool_size'
# Conflicts: # src/main/java/com/couchbase/lite/Manager.java
2 parents b73ee4f + be98b88 commit 725e73a

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

src/main/java/com/couchbase/lite/Manager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,5 +689,13 @@ protected boolean isAutoMigrateBlobStoreFilename() {
689689
private static boolean isWindows() {
690690
return (OS.indexOf("win") >= 0);
691691
}
692+
693+
/**
694+
* @exclude
695+
*/
696+
@InterfaceAudience.Private
697+
public int getExecutorThreadPoolSize() {
698+
return this.options.getExecutorThreadPoolSize();
699+
}
692700
}
693701

src/main/java/com/couchbase/lite/ManagerOptions.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@
66
public class ManagerOptions {
77

88
/**
9-
* No modifications to databases are allowed.
9+
* No modifications to databases are allowed.
1010
*/
1111
private boolean readOnly = false;
1212

1313
/**
14-
* automatically migrate blobstore filename
14+
* automatically migrate blobstore filename
1515
*/
1616
private boolean autoMigrateBlobStoreFilename = false;
1717

18+
/**
19+
* the number of threads to keep in the pool for RemoteRequestExecutor
20+
* ReplicationInternal.java: public static final int EXECUTOR_THREAD_POOL_SIZE = 5;
21+
* https://github.com/couchbase/couchbase-lite-java-core/issues/343
22+
*/
23+
private int executorThreadPoolSize = 0;
24+
1825
public ManagerOptions() {
1926
}
2027

@@ -33,4 +40,12 @@ public boolean isAutoMigrateBlobStoreFilename() {
3340
public void setAutoMigrateBlobStoreFilename(boolean autoMigrateBlobStoreFilename) {
3441
this.autoMigrateBlobStoreFilename = autoMigrateBlobStoreFilename;
3542
}
36-
}
43+
44+
public int getExecutorThreadPoolSize() {
45+
return executorThreadPoolSize;
46+
}
47+
48+
public void setExecutorThreadPoolSize(int executorThreadPoolSize) {
49+
this.executorThreadPoolSize = executorThreadPoolSize;
50+
}
51+
}

src/main/java/com/couchbase/lite/replicator/ReplicationInternal.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ protected void initNetworkReachabilityManager() {
320320

321321
protected void goOnlineInitialStartup() {
322322

323-
remoteRequestExecutor = Executors.newScheduledThreadPool(EXECUTOR_THREAD_POOL_SIZE, new ThreadFactory() {
323+
int executorThreadPoolSize = db.getManager().getExecutorThreadPoolSize() <= 0 ?
324+
EXECUTOR_THREAD_POOL_SIZE: db.getManager().getExecutorThreadPoolSize();
325+
Log.v(Log.TAG_SYNC, "executorThreadPoolSize=" + executorThreadPoolSize);
326+
remoteRequestExecutor = Executors.newScheduledThreadPool(executorThreadPoolSize, new ThreadFactory() {
324327
private int counter = 0;
325328
@Override
326329
public Thread newThread(Runnable r) {

0 commit comments

Comments
 (0)