Skip to content

Commit ca4819a

Browse files
committed
core: Apply ManagedChannelImpl's updateBalancingState() immediately
ffcc360 adjusted updateBalancingState() to require being run within the sync context. However, it still queued the work into the sync context, which was unnecessary. This re-entering the sync context unnecessarily delays the new state from being used.
1 parent a6a041e commit ca4819a

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

core/src/main/java/io/grpc/internal/ManagedChannelImpl.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,24 +1388,18 @@ public void updateBalancingState(
13881388
syncContext.throwIfNotInThisSynchronizationContext();
13891389
checkNotNull(newState, "newState");
13901390
checkNotNull(newPicker, "newPicker");
1391-
final class UpdateBalancingState implements Runnable {
1392-
@Override
1393-
public void run() {
1394-
if (LbHelperImpl.this != lbHelper || panicMode) {
1395-
return;
1396-
}
1397-
updateSubchannelPicker(newPicker);
1398-
// It's not appropriate to report SHUTDOWN state from lb.
1399-
// Ignore the case of newState == SHUTDOWN for now.
1400-
if (newState != SHUTDOWN) {
1401-
channelLogger.log(
1402-
ChannelLogLevel.INFO, "Entering {0} state with picker: {1}", newState, newPicker);
1403-
channelStateManager.gotoState(newState);
1404-
}
1405-
}
1406-
}
14071391

1408-
syncContext.execute(new UpdateBalancingState());
1392+
if (LbHelperImpl.this != lbHelper || panicMode) {
1393+
return;
1394+
}
1395+
updateSubchannelPicker(newPicker);
1396+
// It's not appropriate to report SHUTDOWN state from lb.
1397+
// Ignore the case of newState == SHUTDOWN for now.
1398+
if (newState != SHUTDOWN) {
1399+
channelLogger.log(
1400+
ChannelLogLevel.INFO, "Entering {0} state with picker: {1}", newState, newPicker);
1401+
channelStateManager.gotoState(newState);
1402+
}
14091403
}
14101404

14111405
@Override

0 commit comments

Comments
 (0)