2019-02-02 16:18:25 +08:00
|
|
|
// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
2019-01-17 20:04:17 +08:00
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
2019-02-02 16:18:25 +08:00
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2019-01-17 20:04:17 +08:00
|
|
|
|
|
|
|
package gtimer_test
|
|
|
|
|
|
|
|
import (
|
2019-06-19 09:06:52 +08:00
|
|
|
"fmt"
|
|
|
|
"time"
|
2019-07-29 21:01:19 +08:00
|
|
|
|
|
|
|
"github.com/gogf/gf/os/gtimer"
|
2019-01-17 20:04:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func ExampleAdd() {
|
2019-06-19 09:06:52 +08:00
|
|
|
now := time.Now()
|
|
|
|
interval := 1400 * time.Millisecond
|
|
|
|
gtimer.Add(interval, func() {
|
|
|
|
fmt.Println(time.Now(), time.Duration(time.Now().UnixNano()-now.UnixNano()))
|
|
|
|
now = time.Now()
|
|
|
|
})
|
2019-01-17 20:04:17 +08:00
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
select {}
|
2019-01-17 20:04:17 +08:00
|
|
|
}
|