예제 #1
0
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)
}
예제 #2
0
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

}
예제 #3
0
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)
		}
	}
}
예제 #4
0
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))
}
예제 #5
0
func (s *rmsgSet) contains(rm *RMessage) bool {
	g := ints.Combine(rm.originId, rm.msgId)
	_, ok := s.msgMap[g]
	return ok
}
예제 #6
0
func (s *rmsgSet) remove(rm *RMessage) {
	g := ints.Combine(rm.originId, rm.msgId)
	delete(s.msgMap, g)
}
예제 #7
0
func (s *rmsgSet) add(rm *RMessage) {
	g := ints.Combine(rm.originId, rm.msgId)
	s.msgMap[g] = rm
}