|
|
@ -32,6 +32,8 @@ type StarQueue struct {
|
|
|
|
duration time.Duration
|
|
|
|
duration time.Duration
|
|
|
|
EncodeFunc func([]byte) []byte
|
|
|
|
EncodeFunc func([]byte) []byte
|
|
|
|
DecodeFunc func([]byte) []byte
|
|
|
|
DecodeFunc func([]byte) []byte
|
|
|
|
|
|
|
|
//parseMu sync.Mutex
|
|
|
|
|
|
|
|
restoreMu sync.Mutex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewQueue 建立一个新消息队列
|
|
|
|
// NewQueue 建立一个新消息队列
|
|
|
@ -249,6 +251,8 @@ func bytesMerge(src ...[]byte) []byte {
|
|
|
|
|
|
|
|
|
|
|
|
// Restore 获取收到的信息
|
|
|
|
// Restore 获取收到的信息
|
|
|
|
func (que *StarQueue) Restore(n int) ([]MsgQueue, error) {
|
|
|
|
func (que *StarQueue) Restore(n int) ([]MsgQueue, error) {
|
|
|
|
|
|
|
|
que.restoreMu.Lock()
|
|
|
|
|
|
|
|
defer que.restoreMu.Unlock()
|
|
|
|
var res []MsgQueue
|
|
|
|
var res []MsgQueue
|
|
|
|
dura := time.Duration(0)
|
|
|
|
dura := time.Duration(0)
|
|
|
|
for len(que.MsgPool) < n {
|
|
|
|
for len(que.MsgPool) < n {
|
|
|
|