// Stop stops the bulk indexer, blocking the caller until it is complete.
773952
func (b *BulkIndexer) Stop() {
	ch := make(chan struct{}, 1)
	b.shutdownChan <- ch
	select {
	case <-ch:
		// done
	case <-time.After(time.Second * time.Duration(MAX_SHUTDOWN_SECS)):
		// timeout!
	}
}
986013
func (c *PCPClient) Stop() error {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	if !c.r.mapped {
		return errors.New("trying to stop an already stopped mapping")
	}

	c.stop()

	c.r.mapped = false

	err := c.writer.(*bytewriter.MemoryMappedWriter).Unmap(EraseFileOnStop)
	c.writer = nil
	if err != nil {
		return errors.Wrap(err, "client: error unmapping MemoryMappedBuffer")
	}

	return nil
}
1219110
func (h *Handle) Stop() {
	h.l.Lock()
	defer h.l.Unlock()

	h.watcher.endQuery(h)
}
932793
func (s *SigPool) Stop() error {
	if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) {
		return nil
	}

	close(s.quit)
	s.wg.Wait()

	return nil
}
436784
func Stop() error {
	// This awkward for loop is to avoid a deadlock since
	// inst.Stop() also acquires the instancesMu lock.
	for {
		instancesMu.Lock()
		if len(instances) == 0 {
			instancesMu.Unlock()
			break
		}
		inst := instances[0]
		instancesMu.Unlock()
		if err := inst.Stop(); err != nil {
			log.Printf("[ERROR] Stopping %s: %v", inst.serverType, err)
		}
	}
	return nil
}
1018326
func (s *ServerHTTPS) Stop() error {
	s.m.Lock()
	defer s.m.Unlock()
	if s.httpsServer != nil {
		s.httpsServer.Shutdown(context.Background())
	}
	return nil
}
374848
func (sw *StreamWatcher) Stop() {
	// Call Close() exactly once by locking and setting a flag.
	sw.Lock()
	defer sw.Unlock()
	if !sw.stopped {
		sw.stopped = true
		sw.source.Close()
	}
}
862024
func (c *CouchDB) Stop() error {
	c.mutex.Lock()
	if c.stopped {
		c.mutex.Unlock()
		return errors.Errorf("container %s already stopped", c.containerID)
	}
	c.stopped = true
	c.mutex.Unlock()

	err := c.Client.StopContainer(c.containerID, 0)
	if err != nil {
		return err
	}

	return nil
}
1041209
func (b *BitcoindFilteredChainView) Stop() error {
	// Already shutting down?
	if atomic.AddInt32(&b.stopped, 1) != 1 {
		return nil
	}

	// Shutdown the rpc client, this gracefully disconnects from bitcoind's
	// zmq socket, and cleans up all related resources.
	b.chainClient.Stop()

	b.blockQueue.Stop()

	log.Infof("FilteredChainView stopping")

	close(b.quit)
	b.wg.Wait()

	return nil
}
78347
func (p *Plan) Stop() {
	p.stopLock.Lock()
	defer p.stopLock.Unlock()
	if p.stop {
		return
	}
	p.stop = true
	if p.cancelFunc != nil {
		p.cancelFunc()
	}
	close(p.stopCh)
}
994273
func (c *Container) Stop(ctx context.Context, timeout time.Duration) error {
	if c.Engine == nil {
		return ErrNilEngine
	}
	// 这里 block 的问题很严重，按照目前的配置是 5 分钟一级的 block
	// 一个简单的处理方法是相信 ctx 不相信 engine 自身的处理
	// 另外我怀疑 engine 自己的 timeout 实现是完全的等 timeout 而非结束了就退出
	removeCtx, cancel := context.WithTimeout(ctx, timeout)
	defer cancel()
	return c.Engine.VirtualizationStop(removeCtx, c.ID)
}
8193
func (r *sentReq) stop(err error) {
	r.lock.Lock()
	if !r.stopped {
		r.stopped = true
		r.err = err
		close(r.stopCh)
	}
	r.lock.Unlock()
}
276516
func (pw *ProxyWatcher) Stopping() bool {
	pw.mutex.Lock()
	defer pw.mutex.Unlock()
	return pw.stopped
}
399989
func (p *Provisioner) Stop() error {
	p.stopOnce.Do(p.stopInit)
	p.stopCtxCancel()
	return nil
}
1320727
func (s *Server) Stop() error {
	ctx, cancel := context.WithTimeout(context.Background(), s.connTimeout)
	defer cancel()

	err := s.Server.Shutdown(ctx)
	if err != nil {
		return err
	}

	// signal any TLS governor goroutines to exit
	if s.tlsGovChan != nil {
		close(s.tlsGovChan)
	}

	return nil
}
939992
func (m *ManagerImpl) Stop() error {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	for _, eI := range m.endpoints {
		eI.e.stop()
	}

	if m.server == nil {
		return nil
	}
	m.server.Stop()
	m.wg.Wait()
	m.server = nil
	return nil
}
635055
func (m *manager) Stop() {
	m.clientAccessLock.Lock()
	defer m.clientAccessLock.Unlock()
	if m.stopped {
		return
	}
	close(m.stopCh)
	m.stopped = true
}