DEV Community

邱敬幃 Pardn Chiu
邱敬幃 Pardn Chiu

Posted on

GO-QUEUE@v1.1.2: Priority-based task queue with automatic timeout promotion

cover


REFACTOR

  • task.go: Refactored taskHeap from a slice type to a struct, added tasks and minCap fields to support dynamic minimum capacity.
  • task.go: Updated Len, Less, Swap, Push, and Pop methods of taskHeap to fit the new struct structure.
  • pending.go: Fixed newPending initialization to calculate dynamic minimum capacity based on workers and size (max(16, min(size/8, size/workers))).

PERF

  • task.go: Optimized heap shrink logic, changed trigger condition from capacity > taskHeapMinCap && length < capacity/4 to capacity > minCap*4 && length < capacity/taskHeapMinCapRatio.
  • task.go: Improved shrink capacity calculation, using max(capacity/4, minCap) to ensure it does not fall below the minimum capacity.
  • pending.go: Optimized promoteLocked access efficiency by retrieving the tasks field first to avoid repeated access.

UPDATE

  • new.go: Fixed newPending call, added workers parameter.

FIX

  • new.go: Added debug log for timeout trigger (task.timeout_triggered), recording id, preset, and timeout information.

©️ 2025 邱敬幃 Pardn Chiu

Top comments (0)