// TerminateAfter indicates the maximum number of documents to collect
// for each shard, upon reaching which the query execution will terminate early.
502994
func (s *DeleteByQueryService) TerminateAfter(terminateAfter int) *DeleteByQueryService {
	s.terminateAfter = &terminateAfter
	return s
}
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()
}
1239049
func TerminateAll(matcher Matcher, killDelay time.Duration, log Log) []int {
	return TerminateAllWithProcessesFn(ps.Processes, matcher.Fn(), killDelay, log)
}
948879
func (r *Record) End() int {
	if r.Flags&Unmapped != 0 || len(r.Cigar) == 0 {
		return r.Pos + 1
	}
	pos := r.Pos
	end := pos
	for _, co := range r.Cigar {
		pos += co.Len() * co.Type().Consumes().Reference
		end = max(end, pos)
	}
	return end
}
636510
func (i *PostingsIterator) nextDocNumAtOrAfter(atOrAfter uint64) (uint64, bool, error) {
	if i.normBits1Hit != 0 {
		if i.docNum1Hit == DocNum1HitFinished {
			return 0, false, nil
		}
		if i.docNum1Hit < atOrAfter {
			// advanced past our 1-hit
			i.docNum1Hit = DocNum1HitFinished // consume our 1-hit docNum
			return 0, false, nil
		}
		docNum := i.docNum1Hit
		i.docNum1Hit = DocNum1HitFinished // consume our 1-hit docNum
		return docNum, true, nil
	}

	if i.Actual == nil || !i.Actual.HasNext() {
		return 0, false, nil
	}

	if i.postings == nil || i.postings.postings == i.ActualBM {
		return i.nextDocNumAtOrAfterClean(atOrAfter)
	}

	n := i.Actual.Next()
	for uint64(n) < atOrAfter && i.Actual.HasNext() {
		n = i.Actual.Next()
	}
	if uint64(n) < atOrAfter {
		// couldn't find anything
		return 0, false, nil
	}
	allN := i.all.Next()

	nChunk := n / i.postings.sb.chunkFactor

	// when allN becomes >= to here, then allN is in the same chunk as nChunk.
	allNReachesNChunk := nChunk * i.postings.sb.chunkFactor

	// n is the next actual hit (excluding some postings), and
	// allN is the next hit in the full postings, and
	// if they don't match, move 'all' forwards until they do
	for allN != n {
		// we've reached same chunk, so move the freq/norm/loc decoders forward
		if i.includeFreqNorm && allN >= allNReachesNChunk {
			err := i.currChunkNext(nChunk)
			if err != nil {
				return 0, false, err
			}
		}

		allN = i.all.Next()
	}

	if i.includeFreqNorm && (i.currChunk != nChunk || i.currChunkFreqNorm == nil) {
		err := i.loadChunk(int(nChunk))
		if err != nil {
			return 0, false, fmt.Errorf("error loading chunk: %v", err)
		}
	}

	return uint64(n), true, nil
}
1106858
func (r *controller) Terminate(ctx context.Context) error {
	if err := r.checkClosed(); err != nil {
		return err
	}

	if r.cancelPull != nil {
		r.cancelPull()
	}

	if err := r.adapter.terminate(ctx); err != nil {
		if isUnknownContainer(err) {
			return nil
		}

		return err
	}

	return nil
}
480736
func (c *MongoController) End() revel.Result {
	// This is necessary since End() will be called no matter what
	// (revel.FINALLY) so it may not be connected in which case MongoSession
	// were a nil pointer and panic
	if c.MongoSession != nil {
		c.MongoSession.Close()
	}
	return nil
}
1076733
func (l *udpPacketList) InsertAfter(b, e *udpPacket) {
	a := udpPacketElementMapper{}.linkerFor(b).Next()
	udpPacketElementMapper{}.linkerFor(e).SetNext(a)
	udpPacketElementMapper{}.linkerFor(e).SetPrev(b)
	udpPacketElementMapper{}.linkerFor(b).SetNext(e)

	if a != nil {
		udpPacketElementMapper{}.linkerFor(a).SetPrev(e)
	} else {
		l.tail = e
	}
}
763428
func (ctl *Controller) finishShard(c context.Context, shardID, processedCount int64, shardErr error) error {
	err := shardTxn(c, shardID, func(c context.Context, sh *shard) (save bool, err error) {
		runtime := clock.Now(c).Sub(sh.Created)
		switch {
		case shardErr == errJobAborted:
			logging.Warningf(c, "The job has been aborted, aborting the shard after it has been running %s", runtime)
			sh.State = State_ABORTED
			sh.Error = errJobAborted.Error()
		case shardErr != nil:
			logging.Errorf(c, "The shard processing failed in %s with error: %s", runtime, shardErr)
			sh.State = State_FAIL
			sh.Error = shardErr.Error()
		default:
			logging.Infof(c, "The shard processing finished successfully in %s", runtime)
			sh.State = State_SUCCESS
		}
		sh.ProcessedCount += processedCount
		return true, ctl.requestJobStateUpdate(c, sh.JobID, sh.ID)
	})
	return errors.Annotate(err, "when marking the shard as finished").Err()
}
673743
func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool {
	if event.typ != yaml_DOCUMENT_END_EVENT {
		return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END")
	}
	if !yaml_emitter_write_indent(emitter) {
		return false
	}
	if !event.implicit {
		// [Go] Allocate the slice elsewhere.
		if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
			return false
		}
		if !yaml_emitter_write_indent(emitter) {
			return false
		}
	}
	if !yaml_emitter_flush(emitter) {
		return false
	}
	emitter.state = yaml_EMIT_DOCUMENT_START_STATE
	emitter.tag_directives = emitter.tag_directives[:0]
	return true
}
400558
func (mc *MergeControl) mergeFinish(merge *OneMerge) {
	// forceMerge, addIndexes or abortAllmerges may be waiting on
	// merges to finish
	// notifyAll()

	// It's possible we are called twice, eg if there was an error
	// inside mergeInit()
	if merge.registerDone {
		for _, info := range merge.segments {
			delete(mc.mergingSegments, info)
		}
		merge.registerDone = false
	}

	delete(mc.runningMerges, merge)
	if len(mc.runningMerges) == 0 {
		mc.mergeSignal.Signal()
	}
}
119848
func (c *Conn) TerminateUser(uid uint32) {
	c.object.Call(dbusInterface+".TerminateUser", 0, uid)
}
889541
func (ql *QueryList) Terminate(connID int64) error {
	ql.mu.Lock()
	defer ql.mu.Unlock()
	qd := ql.queryDetails[connID]
	if qd == nil {
		return fmt.Errorf("query %v not found", connID)
	}
	qd.conn.Kill("QueryList.Terminate()", time.Since(qd.start))
	return nil
}
1205850
func (o *Opts) DocAfter(target, newid, template string) *Opts {
	return o.docOffset(1, target, newid, template)
}
371426
func (l *waiterList) InsertAfter(b, e *Entry) {
	a := waiterElementMapper{}.linkerFor(b).Next()
	waiterElementMapper{}.linkerFor(e).SetNext(a)
	waiterElementMapper{}.linkerFor(e).SetPrev(b)
	waiterElementMapper{}.linkerFor(b).SetNext(e)

	if a != nil {
		waiterElementMapper{}.linkerFor(a).SetPrev(e)
	} else {
		l.tail = e
	}
}
708622
func (c *Client) TerminateStream(ctx context.Context, in *s.TerminateStreamRequest, opts ...grpc.CallOption) (
	*empty.Empty, error) {

	_, err := c.bundleRPC(ctx, opts, &s.BatchRequest_Entry{
		Value: &s.BatchRequest_Entry_TerminateStream{TerminateStream: in},
	})
	if err != nil {
		return nil, err
	}

	return &empty.Empty{}, nil
}
50247
func (d *Document) GetWordAfterCursor() string {
	x := d.TextAfterCursor()
	return x[:d.FindEndOfCurrentWord()]
}