-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Open
Copy link
Labels
Type: FeatureNew features or improvements in behaviorNew features or improvements in behavior
Description
Currently, we have a couple of ways to schedule callbacks for execution with the serializer:
TrySchedule
: which is a best effort option to schedule a callbackScheduleOr
: which provides a way for the caller to supply a function that is executed if the callback is not successfully scheduled on the serializer.
See: https://github.com/grpc/grpc-go/blob/master/internal/grpcsync/callback_serializer.go
We have a whole bunch of places which have the following pattern (where the caller wants to wait for the scheduled callback to run, before proceeding):
done := make(chan struct{})
serializer.ScheduleOr(func(context.Context) {
// Do stuff
close(done)
}, func() {
// Set an error somewhere or throw a log message
close(done)
})
<-done
We could introduce a new method to the serializer which supports this pattern of blocking until the provided callback is run. This review thread has some ideas to get started on this: #8499 (comment)
Metadata
Metadata
Assignees
Labels
Type: FeatureNew features or improvements in behaviorNew features or improvements in behavior