Skip to content

Feat/v0.7.0 error handling#10

Merged
ikelaiah merged 5 commits into
mainfrom
feat/v0.7.0-error-handling
Jul 11, 2026
Merged

Feat/v0.7.0 error handling#10
ikelaiah merged 5 commits into
mainfrom
feat/v0.7.0-error-handling

Conversation

@ikelaiah

Copy link
Copy Markdown
Owner

What does this PR do?

Makes v0.7.0 official.

This release adds richer task error handling to both thread pools via the shared TThreadPoolBase implementation:

  • Adds Errors, ErrorCount, ClearErrors, and OnError.
  • Keeps LastError backward-compatible as the most recent task error.
  • Caps stored errors at MAX_STORED_ERRORS = 1000.
  • Adds tests covering error collection, callback behavior, clearing errors, cap behavior, and LastError compatibility.
  • Updates README/API docs/release notes/changelog.
  • Adds new examples for basic error handling, advanced OnError handling, parallel file hashing, and parallel URL fetching.

Local verification completed:

  • Package builds successfully.
  • Test runner builds successfully.
  • Full test suite passes: 43 tests, 0 errors, 0 failures, 0 unfreed memory blocks.
  • All 10 top-level examples build and run locally. ParallelUrlFetcher exercised its runtime error path due local OpenSSL/network issues and exited cleanly.

Related issue

N/A

Type of change

  • 🐛 Bug fix
  • ✨ New feature
  • 📝 Documentation / examples
  • 🔧 Refactor / internal change

Checklist

  • Tests pass locally (lazbuild tests/TestRunner.lpi then run TestRunner)
  • Added/updated tests where it makes sense
  • Updated CHANGELOG.md
  • Updated docs in docs/ if behavior or API changed
  • New units use {$mode objfpc}{$H+}{$J-} and filenames match unit casing

ikelaiah added 5 commits June 13, 2026 11:03
Add a richer error-handling API to both thread pools. LastError is unchanged
and fully backward compatible.

Core (implemented once in TThreadPoolBase, inherited by both pools):
- Errors: TStringArray — every captured task error message, oldest first
- ErrorCount: Integer
- OnError: TThreadPoolErrorEvent — optional callback fired on a worker thread
  per failed task; invoked outside the lock to avoid deadlocks
- ClearErrors — clears the collection and LastError
- MAX_STORED_ERRORS (1000) caps the collection; oldest dropped beyond it
- Removed the now-redundant per-pool FErrorLock; the base class serializes
  error capture

Tests (43 total, +8):
- ThreadPool.Simple.Tests: collection-captures-all, OnError fires per failure,
  ClearErrors resets, cap enforced, LastError back-compat
- ThreadPool.ProducerConsumer.Tests: matching coverage on the second pool

Examples:
- SimpleErrorHandlingBasic — the easy way: poll Errors/ErrorCount/LastError
  after WaitForAll; no callback, class, or locking
- SimpleErrorHandling — advanced: OnError with a thread-safe handler

Docs / housekeeping:
- README, both API docs, CHANGELOG, docs/release-notes-v0.7.0.md updated;
  corrected an inaccurate "error messages include thread IDs" claim (raw messages)
- Bump version to 0.7.0 (README badge, package .lpk)
- Planned/In Progress now points to the 0.8.0 performance milestone
- .gitignore: ignore lazbuild's local packagefiles.xml cache
This is per-developer Claude Code config that was accidentally committed.
Add it to .gitignore and remove it from tracking (local copy is kept).
Add Lazarus/FPC projects demonstrating v0.7.0 error handling for
parallel file hashing and URL fetching. Move v0.5.0 release notes into docs.
@ikelaiah ikelaiah merged commit b36cfa3 into main Jul 11, 2026
4 checks passed
@ikelaiah ikelaiah deleted the feat/v0.7.0-error-handling branch July 11, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant