Skip to content

Commit

Permalink
optimize CamelliaLinearInitializationExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
caojiajun committed Feb 13, 2023
1 parent b6011cc commit cc4f67a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public CamelliaLinearInitializationExecutor(CamelliaLinearInitializationExecutor
this.initializer = config.getInitializer();
this.config = config;
this.name = CamelliaExecutorMonitor.genExecutorName(config.getName());
this.executor = config.getExecutor();
this.executor = new CamelliaHashedExecutor("liner-initialization-" + name, config.getPoolSize(),
config.getPendingQueueSize(), new CamelliaHashedExecutor.AbortPolicy());
this.pendingQueueSize = config.getPendingQueueSize();

CamelliaExecutorMonitor.register(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ public class CamelliaLinearInitializationExecutorConfig<K, T> {

private String name;
private CamelliaLinearInitializationExecutor.Initializer<K, T> initializer;
private CamelliaHashedExecutor executor;
private DynamicValueGetter<Integer> pendingQueueSize = () -> 100000;
private int poolSize = SysUtils.getCpuNum();

public CamelliaLinearInitializationExecutorConfig(String name, CamelliaLinearInitializationExecutor.Initializer<K, T> initializer) {
this.name = name;
this.initializer = initializer;
this.executor = new CamelliaHashedExecutor("liner-initialization-" + name, SysUtils.getCpuNum(), 10000);
}

public CamelliaLinearInitializationExecutorConfig(String name, CamelliaLinearInitializationExecutor.Initializer<K, T> initializer,
DynamicValueGetter<Integer> pendingQueueSize) {
this.name = name;
this.initializer = initializer;
this.executor = new CamelliaHashedExecutor("liner-initialization-" + name, SysUtils.getCpuNum(),
pendingQueueSize, new CamelliaHashedExecutor.AbortPolicy());
this.pendingQueueSize = pendingQueueSize;
}

Expand All @@ -44,19 +41,19 @@ public void setInitializer(CamelliaLinearInitializationExecutor.Initializer<K, T
this.initializer = initializer;
}

public CamelliaHashedExecutor getExecutor() {
return executor;
}

public void setExecutor(CamelliaHashedExecutor executor) {
this.executor = executor;
}

public DynamicValueGetter<Integer> getPendingQueueSize() {
return pendingQueueSize;
}

public void setPendingQueueSize(DynamicValueGetter<Integer> pendingQueueSize) {
this.pendingQueueSize = pendingQueueSize;
}

public int getPoolSize() {
return poolSize;
}

public void setPoolSize(int poolSize) {
this.poolSize = poolSize;
}
}

0 comments on commit cc4f67a

Please sign in to comment.