func (t *Timer) SetCondition(condition Condition) {
	t.condition = condition
}
SetCondition sets the condition used for verifying when the cron job should run
package timer
import (
	"sync"
	"sync/atomic"
	"time"
	"github.com/topfreegames/pitaya/logger"
)
var timerBacklog int
const (
	LoopForever = -1
)
var (
	Manager = &struct {
		incrementID    int64       
		timers         sync.Map    
		ChClosingTimer chan int64  
		ChCreatedTimer chan *Timer
	}{}
	Precision = time.Second
	GlobalTicker *time.Ticker
)
type (
	Func func()
	Condition interface {
		Check(now time.Time) bool
	}
	Timer struct {
		ID        int64          
		fn        Func           
		createAt  int64          
		interval  time.Duration  
		condition Condition      
		elapse    int64          
		closed    int32          
		counter   int            
	}
)
func init() {
	timerBacklog = 1 << 8  
	Manager.ChClosingTimer = make(chan int64, timerBacklog)
	Manager.ChCreatedTimer = make(chan *Timer, timerBacklog)
}
func AddTimer(t *Timer) {
	Manager.timers.Store(t.ID, t)
}
func RemoveTimer(id int64) {
	Manager.timers.Delete(id)
}
func NewTimer(fn Func, interval time.Duration, counter int) *Timer {
	id := atomic.AddInt64(&Manager.incrementID, 1)
	t := &Timer{
		ID:       id,
		fn:       fn,
		createAt: time.Now().UnixNano(),
		interval: interval,
		elapse:   int64(interval),  
		counter:  counter,
	}
	Manager.ChCreatedTimer <- t
	return t
}