func (b *baseToken) WaitTimeout(d time.Duration) bool {
	timer := time.NewTimer(d)
	select {
	case <-b.complete:
		if !timer.Stop() {
			<-timer.C
		}
		return true
	case <-timer.C:
	}
	return false
}
WaitTimeout implements the Token WaitTimeout method.
package mqtt
import (
	"sync"
	"time"
	"github.com/eclipse/paho.mqtt.golang/packets"
)
type PacketAndToken struct {
	p packets.ControlPacket
	t tokenCompletor
}
type Token interface {
	Wait() bool
	WaitTimeout(time.Duration) bool
	Done() <-chan struct{}
	Error() error
}
type TokenErrorSetter interface {
	setError(error)
}
type tokenCompletor interface {
	Token
	TokenErrorSetter
	flowComplete()
}
type baseToken struct {
	m        sync.RWMutex
	complete chan struct{}
	err      error
}
func (b *baseToken) Wait() bool {
	<-b.complete
	return true
}