Пример #1
0
func (j *MyJob) Run(t tq.TimeSetter) {
	if j.nr_exec_times >= 3 {
		fmt.Printf("I'm tired, I will stop.\n")
		t.Stop()
		j.ch <- true
		return
	}
	fmt.Printf("Hello, I have been executed %d time(s).\n", j.nr_exec_times)
	j.nr_exec_times++
}
Пример #2
0
func (j *MyJob) Run(t tq.TimeSetter) {
	fmt.Printf("Hello, I have been executed %d time(s).\n", j.nr_exec_times)

	// After 5 times run, it will stop.
	if j.nr_exec_times >= 5 {
		t.Stop()
		j.ch <- true
		return
	}
	j.nr_exec_times++
}
Пример #3
0
func (j *MyJob) Run(t tq.TimeSetter) {
	if j.nr_exec_times >= 3 {
		fmt.Printf("I'm tired, I will stop.\n")
		t.Stop()
		j.ch <- true
		return
	}
	if j.backoff == 0 {
		j.backoff = 2
	} else {
		j.backoff <<= 1
	}
	t.After(j.backoff)
	fmt.Printf("Hello, I have been executed %d time(s).\n", j.nr_exec_times)
	j.nr_exec_times++
}