mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 16:06:55 +08:00
update
This commit is contained in:
@@ -2,7 +2,6 @@ package bpool
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ByteBuffer provides byte buffer, which can be used for minimizing
|
// ByteBuffer provides byte buffer, which can be used for minimizing
|
||||||
@@ -105,7 +104,7 @@ func (b *ByteBuffer) SetString(s string) {
|
|||||||
|
|
||||||
// String returns string representation of ByteBuffer.B.
|
// String returns string representation of ByteBuffer.B.
|
||||||
func (b *ByteBuffer) String() string {
|
func (b *ByteBuffer) String() string {
|
||||||
return *(*string)(unsafe.Pointer(&b.B))
|
return string(b.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset makes ByteBuffer.B empty.
|
// Reset makes ByteBuffer.B empty.
|
||||||
|
4
pool.go
4
pool.go
@@ -394,6 +394,10 @@ func (wp *Pool) Start(numWorkers int) {
|
|||||||
heap.Push(&wp.taskQueue, task)
|
heap.Push(&wp.taskQueue, task)
|
||||||
}
|
}
|
||||||
wp.taskQueueLock.Unlock()
|
wp.taskQueueLock.Unlock()
|
||||||
|
// Signal workers that tasks are available after restoring from storage
|
||||||
|
wp.taskAvailableCond.L.Lock()
|
||||||
|
wp.taskAvailableCond.Broadcast()
|
||||||
|
wp.taskAvailableCond.L.Unlock()
|
||||||
}
|
}
|
||||||
for i := 0; i < numWorkers; i++ {
|
for i := 0; i < numWorkers; i++ {
|
||||||
wp.wg.Add(1)
|
wp.wg.Add(1)
|
||||||
|
@@ -9,6 +9,12 @@ import (
|
|||||||
|
|
||||||
func RecoverPanic(labelGenerator func() string) {
|
func RecoverPanic(labelGenerator func() string) {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
defer func() {
|
||||||
|
if rr := recover(); rr != nil {
|
||||||
|
// If logging or labelGenerator panics, just print a minimal message
|
||||||
|
fmt.Printf("[PANIC] - error during panic recovery: %v\n", rr)
|
||||||
|
}
|
||||||
|
}()
|
||||||
pc, file, line, ok := runtime.Caller(2)
|
pc, file, line, ok := runtime.Caller(2)
|
||||||
funcName := "unknown"
|
funcName := "unknown"
|
||||||
if ok {
|
if ok {
|
||||||
|
Reference in New Issue
Block a user