This commit is contained in:
sujit
2025-08-16 12:25:55 +05:45
parent 73441ff26b
commit cc57907a05
3 changed files with 11 additions and 2 deletions

View File

@@ -2,7 +2,6 @@ package bpool
import (
"io"
"unsafe"
)
// 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.
func (b *ByteBuffer) String() string {
return *(*string)(unsafe.Pointer(&b.B))
return string(b.B)
}
// Reset makes ByteBuffer.B empty.

View File

@@ -394,6 +394,10 @@ func (wp *Pool) Start(numWorkers int) {
heap.Push(&wp.taskQueue, task)
}
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++ {
wp.wg.Add(1)

View File

@@ -9,6 +9,12 @@ import (
func RecoverPanic(labelGenerator func() string) {
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)
funcName := "unknown"
if ok {