func (t *DownlinkTokens) Next(msg *ttnpb.DownlinkMessage, time time.Time) uint16 {
	key := uint16(atomic.AddUint32(&t.last, 1))
	pos := key % downlinkTokenItems
	t.items[pos] = downlinkToken{
		key:  key,
		msg:  msg,
		time: time,
	}
	return key
}
Next returns a new downlink token for a downlink message.
package io
import (
	"fmt"
	"regexp"
	"strconv"
	"sync/atomic"
	"time"
	"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
)
const downlinkTokenItems = 1 << 4
type downlinkToken struct {
	key  uint16
	msg  *ttnpb.DownlinkMessage
	time time.Time
}
type DownlinkTokens struct {
	last  uint32
	items [downlinkTokenItems]downlinkToken
}