File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
grpc/src/client/load_balancing Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ pub struct ChildManager<T> {
5050 update_sharder : Box < dyn ResolverUpdateSharder < T > > ,
5151 pending_work : Arc < Mutex < HashSet < usize > > > ,
5252 runtime : Arc < dyn Runtime > ,
53+ updated : bool ,
5354}
5455
5556struct Child < T > {
@@ -94,6 +95,7 @@ impl<T> ChildManager<T> {
9495 children : Default :: default ( ) ,
9596 pending_work : Default :: default ( ) ,
9697 runtime,
98+ updated : false ,
9799 }
98100 }
99101
@@ -158,8 +160,14 @@ impl<T> ChildManager<T> {
158160 // Update the tracked state if the child produced an update.
159161 if let Some ( state) = channel_controller. picker_update {
160162 self . children [ child_idx] . state = state;
163+ self . updated = true ;
161164 } ;
162165 }
166+
167+ /// Returns true if a child has produced an update and resets flag to false.
168+ pub fn has_updated ( & mut self ) -> bool {
169+ mem:: take ( & mut self . updated )
170+ }
163171}
164172
165173impl < T : PartialEq + Hash + Eq + Send + Sync + ' static > LbPolicy for ChildManager < T > {
Original file line number Diff line number Diff line change @@ -276,4 +276,4 @@ impl LbPolicyBuilder for StubPolicyBuilder {
276276
277277pub fn reg_stub_policy ( name : & ' static str , funcs : StubPolicyFuncs ) {
278278 super :: GLOBAL_LB_REGISTRY . add_builder ( StubPolicyBuilder { name, funcs } )
279- }
279+ }
You can’t perform that action at this time.
0 commit comments