func (t *Ticker) Tick(m *RMessage) (ticked bool) { val := ints.Combine(m.originId, m.msgId) if t.r == nil { t.r = newRoot(val) } return t.r.tick(val) }
func (t *simpleTicker) tick(m *RMessage) bool { g := ints.Combine(m.originId, m.msgId) if t.guidMap[g] { return false } t.guidMap[g] = true return true }
func TestGuidFuns(t *testing.T) { r := rand.New(rand.NewSource(1)) for i := 0; i < 1000; i++ { traderId := r.Uint32() tradeId := r.Uint32() guid := ints.Combine(traderId, tradeId) cTraderId := ints.High32(guid) cTradeId := ints.Low32(guid) if cTraderId != traderId { t.Errorf("Expecting traderId '%s' found '%s'", traderId, cTraderId) } if cTradeId != tradeId { t.Errorf("Expecting tradeId '%s' found '%s'", tradeId, cTradeId) } } }
func (o *OrderNode) CopyFrom(from *msg.Message) { o.amount = from.Amount o.stockId = from.StockId o.kind = from.Kind o.setup(from.Price, ints.Combine(from.TraderId, from.TradeId)) }
func (s *rmsgSet) contains(rm *RMessage) bool { g := ints.Combine(rm.originId, rm.msgId) _, ok := s.msgMap[g] return ok }
func (s *rmsgSet) remove(rm *RMessage) { g := ints.Combine(rm.originId, rm.msgId) delete(s.msgMap, g) }
func (s *rmsgSet) add(rm *RMessage) { g := ints.Combine(rm.originId, rm.msgId) s.msgMap[g] = rm }