- timer task shceuled to order goroutine to avoid concurrent problem.
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/baseapi/utils/routinepool"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
@@ -18,12 +19,17 @@ const (
|
||||
DefaultOrderCacheTimeout = 24 * time.Hour
|
||||
)
|
||||
|
||||
var (
|
||||
routinePool *routinepool.Pool
|
||||
)
|
||||
|
||||
type SyncMapWithTimeout struct {
|
||||
sync.Map
|
||||
}
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
routinePool = routinepool.New(1000, 1000)
|
||||
}
|
||||
|
||||
func (m *SyncMapWithTimeout) StoreWithTimeout(key, value interface{}, timeout time.Duration) {
|
||||
@@ -142,3 +148,15 @@ func StandardPrice2Int(value float64) int64 {
|
||||
func IntPrice2StandardString(value int64) string {
|
||||
return fmt.Sprintf("%.2f", IntPrice2Standard(value))
|
||||
}
|
||||
|
||||
func CallMsgHandler(handler func(), primaryID string) {
|
||||
routinePool.CallFun(func() {
|
||||
handler()
|
||||
}, primaryID)
|
||||
}
|
||||
|
||||
func CallMsgHandlerAsync(handler func(), primaryID string) {
|
||||
routinePool.CallFunAsync(func() {
|
||||
handler()
|
||||
}, primaryID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user