/* Calls StoredFieldsWriter.startDocument, aborting the segment if it hits any error. */
542637
func (c *DefaultIndexingChain) startStoredFields() (err error) {
	var success = false
	defer func() {
		if !success {
			c.docWriter.setAborting()
		}
	}()

	if err = c.initStoredFieldsWriter(); err != nil {
		return
	}
	if err = c.storedFieldsWriter.StartDocument(); err != nil {
		return
	}
	success = true

	c.lastStoredDocId++
	return nil
}
1062188
func (w *IndexWriter) startCommit(toSync *SegmentInfos) error {
	w.testPoint("startStartCommit")
	assert(w.pendingCommit == nil)
	assert2(w.tragedy == nil, "this writer hit an unrecoverable error; cannot commit\n%v", w.tragedy)

	if w.infoStream.IsEnabled("IW") {
		w.infoStream.Message("IW", "startCommit(): start")
	}

	if err := func() error {
		w.Lock()
		defer w.Unlock()

		assertn(w.lastCommitChangeCount <= w.changeCount,
			"lastCommitChangeCount=%v changeCount=%v", w.lastCommitChangeCount, w.changeCount)
		if w.pendingCommitChangeCount == w.lastCommitChangeCount {
			if w.infoStream.IsEnabled("IW") {
				w.infoStream.Message("IW", "  skip startCommit(): no changes pending")
			}
			w.deleter.decRefFiles(w.filesToCommit)
			w.filesToCommit = nil
			return nil
		}

		if w.infoStream.IsEnabled("IW") {
			w.infoStream.Message("IW", "startCommit index=%v changeCount=%v",
				w.readerPool.segmentsToString(toSync.Segments), w.changeCount)
		}

		return w.assertFilesExist(toSync)
	}(); err != nil {
		return err
	}

	w.testPoint("midStartCommit")

	var pendingCommitSet = false
	defer func() {
		w.Lock()
		defer w.Unlock()

		// Have out master segmentInfos record the generations we just
		// prepared. We do this on error or success so we don't
		// double-write a segments_N file.
		w.segmentInfos.updateGeneration(toSync)

		if !pendingCommitSet {
			if w.infoStream.IsEnabled("IW") {
				w.infoStream.Message("IW", "hit error committing segments file")
			}

			// Hit error
			w.deleter.decRefFiles(w.filesToCommit)
			w.filesToCommit = nil
		}
	}()

	w.testPoint("midStartCommit2")
	err := func() (err error) {
		w.Lock()
		defer w.Unlock()

		assert(w.pendingCommit == nil)
		assert(w.segmentInfos.generation == toSync.generation)

		// Eror here means nothing is prepared (this method unwinds
		// everything it did on an error)
		err = toSync.prepareCommit(w.directory)
		if err != nil {
			return err
		}
		fmt.Println("DONE prepareCommit")

		pendingCommitSet = true
		w.pendingCommit = toSync
		return nil
	}()
	if err != nil {
		return err
	}

	// This call can take a long time -- 10s of seconds or more. We do
	// it without syncing on this:
	var success = false
	var filesToSync []string
	defer func() {
		if !success {
			pendingCommitSet = false
			w.pendingCommit = nil
			toSync.rollbackCommit(w.directory)
		}
	}()

	filesToSync = toSync.files(w.directory, false)
	err = w.directory.Sync(filesToSync)
	if err != nil {
		return err
	}
	success = true

	if w.infoStream.IsEnabled("IW") {
		w.infoStream.Message("IW", "done all syncs: %v", filesToSync)
	}

	w.testPoint("midStartCommitSuccess")
	w.testPoint("finishStartCommit")
	return nil
}
1170025
func (a *addrBook) OnStart() error {
	if err := a.BaseService.OnStart(); err != nil {
		return err
	}
	a.loadFromFile(a.filePath)

	// wg.Add to ensure that any invocation of .Wait()
	// later on will wait for saveRoutine to terminate.
	a.wg.Add(1)
	go a.saveRoutine()

	return nil
}
352824
func (h *DocumentHandler) handleGetDocument(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	d, namspace, err := h.getDocument(w, r)
	if err != nil {
		EncodeError(ctx, err, w)
		return
	}

	if err := encodeResponse(ctx, w, http.StatusOK, newDocumentResponse(namspace, d)); err != nil {
		logEncodingError(h.Logger, r, err)
		return
	}
}
176592
func (md *MDOpsStandard) startOfValidatedChainForLeaf(
	tlfID tlf.ID, leafRev kbfsmd.Revision) kbfsmd.Revision {
	md.lock.Lock()
	defer md.lock.Unlock()
	revs, ok := md.leafChainsValidated[tlfID]
	if !ok {
		return leafRev
	}
	min, ok := revs[leafRev]
	if !ok {
		return leafRev
	}
	return min
}
1077237
func (mr *MockProcessorMockRecorder) Start(ctx, eventInfo interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockProcessor)(nil).Start), ctx, eventInfo)
}
7155
func NewStartWorkerArgs(scopeURL string) *StartWorkerArgs {
	args := new(StartWorkerArgs)
	args.ScopeURL = scopeURL
	return args
}
87129
func (p *contentProvider) setDocument(docID uint32) {
	fileStart := p.id.boundaries[docID]

	p.idx = docID
	p.fileSize = p.id.boundaries[docID+1] - fileStart

	p._nl = nil
	p._sects = nil
	p._data = nil
}
494216
func (sc *scanner) startToken(val *tokenValue) {
	sc.token = sc.rest
	val.raw = ""
	val.pos = sc.pos
}
1286871
func (p *printer) writeStart(start *StartElement) error {
	if start.Name.Local == "" {
		return fmt.Errorf("xml: start tag with no name")
	}

	p.tags = append(p.tags, start.Name)
	p.markPrefix()

	p.writeIndent(1)
	p.WriteByte('<')
	p.WriteString(start.Name.Local)

	if start.Name.Space != "" {
		p.WriteString(` xmlns="`)
		p.EscapeString(start.Name.Space)
		p.WriteByte('"')
	}

	// Attributes
	for _, attr := range start.Attr {
		name := attr.Name
		if name.Local == "" {
			continue
		}
		p.WriteByte(' ')
		if name.Space != "" {
			p.WriteString(p.createAttrPrefix(name.Space))
			p.WriteByte(':')
		}
		p.WriteString(name.Local)
		p.WriteString(`="`)
		p.EscapeString(attr.Value)
		p.WriteByte('"')
	}
	p.WriteByte('>')
	return nil
}
183155
func (s *IncrementStat) Start() {
	s.m.Lock()
	defer s.m.Unlock()
	s.c = 0
	s.isStarted = true
}
608120
func (w *workManager) Start() {

	w.mutex.Lock()
	defer w.mutex.Unlock()

	if w.state == workManagerStopped {
		w.state = workManagerRunning
		go func() {
			for {
				select {
				case <-w.collectq.Err:
					//TODO: log error
				case <-w.processq.Err:
					//TODO: log error
				case <-w.publishq.Err:
					//TODO: log error
				case <-w.kill:
					return
				}
			}
		}()
	}
}
204983
func handleExtensionsResolveFieldDidStart(exts []Extension, p *executionContext, i *ResolveInfo) ([]gqlerrors.FormattedError, resolveFieldFinishFuncHandler) {
	fs := map[string]ResolveFieldFinishFunc{}
	errs := gqlerrors.FormattedErrors{}
	for _, ext := range p.Schema.extensions {
		var (
			ctx      context.Context
			finishFn ResolveFieldFinishFunc
		)
		// catch panic from an extension's resolveFieldDidStart function
		func() {
			defer func() {
				if r := recover(); r != nil {
					errs = append(errs, gqlerrors.FormatError(fmt.Errorf("%s.ResolveFieldDidStart: %v", ext.Name(), r.(error))))
				}
			}()
			ctx, finishFn = ext.ResolveFieldDidStart(p.Context, i)
			// update context
			p.Context = ctx
			fs[ext.Name()] = finishFn
		}()
	}
	return errs, func(val interface{}, err error) []gqlerrors.FormattedError {
		extErrs := gqlerrors.FormattedErrors{}
		for name, finishFn := range fs {
			func() {
				// catch panic from a finishFn
				defer func() {
					if r := recover(); r != nil {
						extErrs = append(extErrs, gqlerrors.FormatError(fmt.Errorf("%s.ResolveFieldFinishFunc: %v", name, r.(error))))
					}
				}()
				finishFn(val, err)
			}()
		}
		return extErrs
	}
}
576941
func (s *SegmentBase) VisitDocument(num uint64, visitor segment.DocumentFieldValueVisitor) error {
	vdc := visitDocumentCtxPool.Get().(*visitDocumentCtx)
	defer visitDocumentCtxPool.Put(vdc)
	return s.visitDocument(vdc, num, visitor)
}
938289
func (mr *MockServerManagerMockRecorder) Start(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockServerManager)(nil).Start), arg0, arg1, arg2, arg3)
}
276480
func (h *handler) startCallProc(fn func(*callProc)) {
	h.callWG.Add(1)
	go func() {
		ctx, cancel := context.WithCancel(h.rootCtx)
		defer h.callWG.Done()
		defer cancel()
		fn(&callProc{ctx: ctx})
	}()
}
573179
func (h *TermsHashPerFieldImpl) start(field IndexableField, first bool) bool {
	if h.termAtt = h.fieldState.termAttribute; h.termAtt != nil {
		// EmptyTokenStream can have nil term att
		h.termBytesRef = h.termAtt.BytesRef()
	}
	if h.nextPerField != nil {
		h.doNextCall = h.nextPerField.start(field, first)
	}
	return true
}