// Cancel cancels the consumers of the stream, interrupting the stream encoding.
//
// After calling cancel, Done() will return a closed channel.
517466
func (s *StreamEncoder) Cancel(err error) {
	s.mux.Lock()
	defer s.mux.Unlock()
	
	select {
	case <-s.done:
	default:
		s.err = err
		close(s.done)
	}
}
537613
func (b *Backend) Cancel(ctx context.Context, id string) error {
	return b.buildkit.Cancel(ctx, id)
}
1314413
func (this *MirrorMaker) Stop() {
	consumerCloseChannels := make([]<-chan bool, 0)
	for _, consumer := range this.consumers {
		consumerCloseChannels = append(consumerCloseChannels, consumer.Close())
	}

	for _, ch := range consumerCloseChannels {
		<-ch
	}

	for _, ch := range this.messageChannels {
		close(ch)
	}

	//TODO maybe drain message channel first?
	for _, producer := range this.producers {
		producer.Close()
	}

	Info("", "Sending stopped")
	this.stopped <- struct{}{}
	Info("", "Sent stopped")
}
375842
func (c *cancel) Cancel(id jsonrpc2.ID) {
	var cancel func()
	c.mu.Lock()
	if c.m != nil {
		cancel = c.m[id]
		delete(c.m, id)
	}
	c.mu.Unlock()
	if cancel != nil {
		cancel()
	}
}
366287
func (e *Event) Cancel(err ...error) {
	e.canceled = true

	if len(err) > 0 {
		e.Err = err[0]
	}
}
175010
func (m *MockStream) CancelRead(arg0 protocol.ApplicationErrorCode) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "CancelRead", arg0)
}
249062
func (this *Future) Cancel() (e error) {
	return this.setResult(&PromiseResult{CANCELLED, RESULT_CANCELLED})
}
904237
func (b *baseBackoff) cancel() {
	if b.next != nil {
		close(b.next)
		b.next = nil
	}
	b.cancelFunc()
}
857028
func (c Client) Cancel(id string, params *stripe.SubscriptionCancelParams) (*stripe.Subscription, error) {
	path := stripe.FormatURLPath("/v1/subscriptions/%s", id)
	sub := &stripe.Subscription{}
	err := c.B.Call(http.MethodDelete, path, c.Key, params, sub)
	return sub, err
}
572658
func (q *Queue) Cancel() error {
	select {
	case <-q.cancelled:
		// already cancelled, no-op
		return nil
	default:
		// mark the queue as cancelled
		close(q.cancelled)
		// Close the Queue, that will wait for pending commands to drain
		// will unblock any callers waiting on q.Block
		return q.Close()
	}
}
755623
func (c *Closer) Close() {
	// Lock the mutex
	c.mutex.Lock()
	defer c.mutex.Unlock()

	// Just return if already closed.
	if c.IsClosed() {
		return
	}

	// Close the channel.
	close(c.IsClosedChan)

	// Emit the function.
	c.f()
}
537496
func (p *Publisher) Cancel() {
	p.m.Lock()
	defer p.m.Unlock()

	if !p.dead {
		close(p.stop)
		p.dead = true
	}
}
96713
func (s *Stoppable) StopChannel() <-chan struct{} {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	if s.stopChannel == nil {
		s.stopChannel = make(chan struct{})
	}
	return s.stopChannel
}
379887
func (c *Canceller) Cancel() {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	c.cancel()
}
1240756
func (b *AllocBroadcaster) stop(id int) {
	b.mu.Lock()
	defer b.mu.Unlock()

	// If broadcaster has been closed there's nothing more to do.
	if b.closed {
		return
	}

	l, ok := b.listeners[id]
	if !ok {
		// If this listener has been stopped already there's nothing
		// more to do.
		return
	}

	close(l)
	delete(b.listeners, id)
}
654379
func (mc *mysqlConn) cancel(err error) {
	mc.canceled.Set(err)
	mc.cleanup()
}
526414
func (d *Downloader) Terminate() {
	// Close the termination channel (make sure double close is allowed)
	d.quitLock.Lock()
	select {
	case <-d.quitCh:
	default:
		close(d.quitCh)
	}
	d.quitLock.Unlock()

	// Cancel any pending download requests
	d.Cancel()
}