Skip to content

Commit 0f9fa68

Browse files
committed
repeat
1 parent 0d4b20d commit 0f9fa68

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

repeat.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package transdsl
2+
3+
import (
4+
"time"
5+
)
6+
7+
type Repeat struct {
8+
MaxTimes int
9+
TimeLen time.Duration //ms
10+
Fragment Fragment
11+
}
12+
13+
func (this *Repeat) Exec(transInfo *TransInfo) error {
14+
flag := false
15+
if this.MaxTimes < 0 {
16+
flag = true
17+
}
18+
19+
for i := 0; flag || i < this.MaxTimes; i++ {
20+
this.Fragment.Exec(transInfo)
21+
<-time.After(this.TimeLen * time.Millisecond)
22+
}
23+
return nil
24+
}
25+
26+
func (this *Repeat) Rollback(transInfo *TransInfo) {
27+
this.Fragment.Rollback(transInfo)
28+
}
29+

0 commit comments

Comments
 (0)