示例#1
0
func TestSchedTrigger(t *testing.T) {
	q := new(vector.Vector)
	d := int64(15e8)

	t0 := time.Nanoseconds()
	ts := t0 + d
	schedTrigger(q, 1, t0, d)

	assert.Equal(t, 1, q.Len())
	f, ok := q.At(0).(trigger)
	assert.Tf(t, ok, "expected a trigger, got a %T", q.At(0))
	assert.Equal(t, int64(1), f.n)
	assert.T(t, f.t == ts)
}
示例#2
0
func applyTriggers(packets, ticks *vector.Vector, now int64, tpl *msg) (n int) {
	for ticks.Len() > 0 {
		tt := ticks.At(0).(trigger)
		if tt.t > now {
			break
		}

		heap.Pop(ticks)

		p := new(packet)
		p.msg = *tpl
		p.msg.Seqn = &tt.n
		log.Println("applying", *p.Seqn, msg_Cmd_name[int32(*p.Cmd)])
		heap.Push(packets, p)
		n++
	}
	return
}