func (js *JobScheduler) Stop() error {
	if !js.Latch.CanStop() {
		return async.ErrCannotStop
	}

	ctx := js.withBaseContext(js.Background())
	js.Latch.Stopping()

	if current := js.Current(); current != nil {
		gracePeriod := js.Config().ShutdownGracePeriodOrDefault()
		if gracePeriod > 0 {
			var cancel func()
			ctx, cancel = js.withTimeoutOrCancel(ctx, gracePeriod)
			defer cancel()
			js.waitCurrentComplete(ctx)
		}
	}
	if current := js.Current(); current != nil && current.Status == JobInvocationStatusRunning {
		current.Cancel()
	}

	<-js.Latch.NotifyStopped()
	js.Latch.Reset()
	js.NextRuntime = Zero
	return nil
}
// Stop stops the scheduler.
Stop stops the scheduler.
// Stop stops the scheduler .
func (js *JobScheduler) Stop() error {
	if !js.Latch.CanStop() {
		return async.ErrCannotStop
	}
	ctx := js.withBaseContext(js.Background())
	js.Latch.Stopping()
	if current := js.Current(); current != nil {
		gracePeriod := js.Config().ShutdownGracePeriodOrDefault()
		if gracePeriod > 0 {
			var cancel func()
			ctx, cancel = js.withTimeoutOrCancel(ctx, gracePeriod)
			defer cancel()
			js.waitCurrentComplete(ctx)
		}
	}
	if current := js.Current(); current != nil && current.Status == JobInvocationStatusRunning {
		current.Cancel()
	}
	<-js.Latch.NotifyStopped()
	js.Latch.Reset()
	js.NextRuntime = Zero
	return nil
}
func ( js * JobScheduler ) Stop ( ) error { if ! js . Latch . CanStop ( ) { return async . ErrCannotStop } ctx := js . withBaseContext ( js . Background ( ) ) js . Latch . Stopping ( ) if current := js . Current ( ) ; current != nil { gracePeriod := js . Config ( ) . ShutdownGracePeriodOrDefault ( ) if gracePeriod > 0 { var cancel func ( ) ctx , cancel = js . withTimeoutOrCancel ( ctx , gracePeriod ) defer cancel ( ) js . waitCurrentComplete ( ctx ) } } if current := js . Current ( ) ; current != nil && current . Status == JobInvocationStatusRunning { current . Cancel ( ) } <- js . Latch . NotifyStopped ( ) js . Latch . Reset ( ) js . NextRuntime = Zero return nil }
Stop stops the scheduler.
Stop stops the scheduler .