MCPcopy
hub / github.com/NVIDIA/aistore / setAbortedTo

Method setAbortedTo

dsort/manager.go:611–626  ·  view source on GitHub ↗

setAbortedTo updates aborted state. If aborted is set to true and sort is not yet finished. We need to inform current phase about abort (closing channel) and mark that we will wait until it is finished. PRECONDITION: `m.mu` must be locked.

(aborted bool)

Source from the content-addressed store, hash-verified

609//
610// PRECONDITION: `m.mu` must be locked.
611func (m *Manager) setAbortedTo(aborted bool) {
612 if aborted {
613 // If not finished and not yet aborted we should mark that we will wait.
614 if m.inProgress() && !m.aborted() {
615 close(m.state.doneCh)
616 m.state.wg.Add(1)
617 }
618 } else {
619 // This is invoked when starting - on start doneCh should be open and
620 // closed when aborted. wg is used to keep all waiting process on finish.
621 m.state.doneCh = make(chan struct{})
622 m.state.wg = &sync.WaitGroup{}
623 }
624 m.state.aborted.Store(aborted)
625 m.Metrics.setAbortedTo(aborted)
626}
627
628func (m *Manager) lock() {
629 m.mu.Lock()

Callers 2

initMethod · 0.95
abortMethod · 0.95

Calls 4

inProgressMethod · 0.95
abortedMethod · 0.95
AddMethod · 0.65
StoreMethod · 0.45

Tested by

no test coverage detected