func (c *CancellationListener) Listen(ctx context.Context, abortFn func()) {
	c.aborted = false
	select {
	case <-ctx.Done():
		if ctx.Err() == context.Canceled {
			c.aborted = true
			abortFn()
		}
		<-c.done
	case <-c.done:
	}
}
Listen blocks until the provided context is cancelled or listening is aborted via the StopListening function. If this
detects that the context has been cancelled (i.e. ctx.Err() == context.Canceled), the provided callback is called to
abort in-progress work. Even if the context expires, this function will block until StopListening is called.
package internal
import "context"
type CancellationListener struct {
	aborted bool
	done    chan struct{}
}
func NewCancellationListener() *CancellationListener {
	return &CancellationListener{
		done: make(chan struct{}),
	}
}