Skip to content

time: add Ticker.Reset #33184

@namewxt1220

Description

@namewxt1220

What version of Go are you using (go version)?

go 1.12

Does this issue reproduce with the latest release?

yes.

What operating system and processor architecture are you using (go env)?

linux amd64

What did you do?

I added the api reset function.

What did you expect to see?

I hope that the proposal will take effect,because sometimes we need to adjust the time dynamically.
This is not a problem,this is just a suggestion.
Please read the following.thanks.

api:

// Reset duration to reset a ticker.
func (t *Ticker) Reset(d Duration) bool {
	if t.r.f == nil {
		panic("time: Reset called on uninitialized Ticker")
	}
	w := when(d)
	active := stopTimer(&t.r)
	t.r.when = w
	t.r.period = int64(d)
	startTimer(&t.r)
	return active
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions