(tps int)
| 37 | } |
| 38 | |
| 39 | func (mgr *TickManager) SetFrequency(tps int) error { |
| 40 | mgr.mu.RLock() |
| 41 | defer mgr.mu.RUnlock() |
| 42 | |
| 43 | if tps == 0 { |
| 44 | return fmt.Errorf("0 tps is not allowed. Use mgr.Freeze instead") |
| 45 | } |
| 46 | |
| 47 | d := time.Second / time.Duration(tps) |
| 48 | mgr.d.Store(int64(d)) |
| 49 | |
| 50 | for _, ticker := range mgr.tickers { |
| 51 | ticker.Reset(d) |
| 52 | } |
| 53 | |
| 54 | /*mgr.b.Range(func(u uuid.UUID, s session.Session) bool { |
| 55 | s.SetTickState(float32(tps), false) |
| 56 | return true |
| 57 | })*/ |
| 58 | |
| 59 | return nil |
| 60 | } |
| 61 | |
| 62 | func (mgr *TickManager) Freeze() { |
| 63 | for _, ticker := range mgr.tickers { |
nothing calls this directly
no outgoing calls
no test coverage detected