tryScaleUpBy() — netty Function Reference
Architecture documentation for the tryScaleUpBy() function in AutoScalingEventExecutorChooserFactory.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a4304eb6_db6c_91df_93c2_2b3acb53fc85["tryScaleUpBy()"] bb4797cf_7318_6bbb_4c87_1f53888dd980["AutoScalingEventExecutorChooser"] a4304eb6_db6c_91df_93c2_2b3acb53fc85 -->|defined in| bb4797cf_7318_6bbb_4c87_1f53888dd980 178c3324_6aa0_719a_b4ab_65660a5ce63c["EventExecutor()"] 178c3324_6aa0_719a_b4ab_65660a5ce63c -->|calls| a4304eb6_db6c_91df_93c2_2b3acb53fc85 0051a9bb_2eac_9138_da01_67fb084baff0["run()"] 0051a9bb_2eac_9138_da01_67fb084baff0 -->|calls| a4304eb6_db6c_91df_93c2_2b3acb53fc85 0ad7a22b_c606_581b_a4ef_ecd45fd409ef["AutoScalingState()"] a4304eb6_db6c_91df_93c2_2b3acb53fc85 -->|calls| 0ad7a22b_c606_581b_a4ef_ecd45fd409ef style a4304eb6_db6c_91df_93c2_2b3acb53fc85 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java lines 207–256
private void tryScaleUpBy(int amount) {
if (amount <= 0) {
return;
}
for (;;) {
AutoScalingState oldState = state.get();
if (oldState.activeChildrenCount >= maxChildren) {
return;
}
int canAdd = Math.min(amount, maxChildren - oldState.activeChildrenCount);
List<EventExecutor> wokenUp = new ArrayList<>(canAdd);
final long startIndex = oldState.nextWakeUpIndex;
for (int i = 0; i < executors.length; i++) {
EventExecutor child = executors[(int) Math.abs((startIndex + i) % executors.length)];
if (wokenUp.size() >= canAdd) {
break; // We have woken up all the threads we reserved.
}
if (child instanceof SingleThreadEventExecutor) {
SingleThreadEventExecutor stee = (SingleThreadEventExecutor) child;
if (stee.isSuspended()) {
stee.execute(NO_OOP_TASK);
wokenUp.add(stee);
}
}
}
if (wokenUp.isEmpty()) {
return;
}
// Create the new state.
List<EventExecutor> newActiveList = new ArrayList<>(oldState.activeExecutors.length + wokenUp.size());
Collections.addAll(newActiveList, oldState.activeExecutors);
newActiveList.addAll(wokenUp);
AutoScalingState newState = new AutoScalingState(
oldState.activeChildrenCount + wokenUp.size(),
startIndex + wokenUp.size(),
newActiveList.toArray(new EventExecutor[0]));
if (state.compareAndSet(oldState, newState)) {
return;
}
// CAS failed, another thread changed the state. Loop again to retry.
}
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does tryScaleUpBy() do?
tryScaleUpBy() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java.
Where is tryScaleUpBy() defined?
tryScaleUpBy() is defined in common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java at line 207.
What does tryScaleUpBy() call?
tryScaleUpBy() calls 1 function(s): AutoScalingState.
What calls tryScaleUpBy()?
tryScaleUpBy() is called by 2 function(s): EventExecutor, run.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free