Skip to content

Commit 7e6d4fe

Browse files
authored
Merge pull request #8 from ikelaiah/feat/towards-v0.6
chore(release): v0.6.0
2 parents a0be559 + 624aa30 commit 7e6d4fe

31 files changed

Lines changed: 502 additions & 62 deletions

.claude/settings.local.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
22
"permissions": {
33
"allow": [
4-
"Bash(wc -l /c/Users/iwank/Documents/github/threadpool-fp/src/*.pas)"
4+
"Bash(wc -l /c/Users/iwank/Documents/github/threadpool-fp/src/*.pas)",
5+
"Bash(grep -iE '\\\\.\\(o|ppu|a|compiled|bak|lps|res\\)$|/lib/|/backup/')",
6+
"Bash(grep -iE 'threadpool.*\\\\.pas$|\\\\.lpk$|\\\\.lpi$|\\\\.lpr$')",
7+
"Bash(grep -iE '\\\\.\\(o|ppu|bak\\)$|/lib/|/backup/')",
8+
"Bash(fpc -iV)",
9+
"Bash(grep '\\\\.lpi$')",
10+
"Bash(lazbuild tests/TestRunner.lpi)",
11+
"Bash(git remote *)",
12+
"Bash(git status *)"
513
]
614
}
715
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 🐛 Bug Report
2+
description: Report something that isn't working as expected
3+
labels: ["bug"]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: Thanks for taking the time to file a bug report!
8+
- type: textarea
9+
id: what-happened
10+
attributes:
11+
label: What happened?
12+
description: A clear description of the bug, including what you expected instead.
13+
validations:
14+
required: true
15+
- type: textarea
16+
id: repro
17+
attributes:
18+
label: Steps to reproduce
19+
description: A minimal code snippet or the steps that trigger the problem.
20+
placeholder: |
21+
1. Create a TSimpleThreadPool with ...
22+
2. Queue ...
23+
3. Call WaitForAll ...
24+
render: pascal
25+
validations:
26+
required: true
27+
- type: dropdown
28+
id: pool
29+
attributes:
30+
label: Which implementation?
31+
options:
32+
- ThreadPool.Simple
33+
- ThreadPool.ProducerConsumer
34+
- Both / not sure
35+
validations:
36+
required: true
37+
- type: input
38+
id: fpc-version
39+
attributes:
40+
label: Free Pascal version
41+
placeholder: "3.2.2"
42+
validations:
43+
required: true
44+
- type: input
45+
id: lazarus-version
46+
attributes:
47+
label: Lazarus version (if used)
48+
placeholder: "3.6.0"
49+
- type: dropdown
50+
id: os
51+
attributes:
52+
label: Operating system
53+
options:
54+
- Windows
55+
- Linux
56+
- macOS
57+
- Other
58+
validations:
59+
required: true
60+
- type: textarea
61+
id: extra
62+
attributes:
63+
label: Anything else?
64+
description: Logs, error messages, or context that might help.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: 💬 Questions & Discussion
4+
url: https://github.com/ikelaiah/threadpool-fp/discussions
5+
about: Ask usage questions or share what you built.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 💡 Feature Request
2+
description: Suggest an idea or improvement
3+
labels: ["enhancement"]
4+
body:
5+
- type: textarea
6+
id: problem
7+
attributes:
8+
label: What problem would this solve?
9+
description: Describe the use case or pain point motivating the request.
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: proposal
14+
attributes:
15+
label: Proposed solution
16+
description: What would you like to see? An API sketch is welcome.
17+
render: pascal
18+
- type: textarea
19+
id: alternatives
20+
attributes:
21+
label: Alternatives considered
22+
description: Other approaches or workarounds you've thought about.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- Thanks for contributing! Please fill out the sections below. -->
2+
3+
## What does this PR do?
4+
5+
<!-- A clear description of the change and the motivation behind it. -->
6+
7+
## Related issue
8+
9+
<!-- e.g. Closes #123 -->
10+
11+
## Type of change
12+
13+
- [ ] 🐛 Bug fix
14+
- [ ] ✨ New feature
15+
- [ ] 📝 Documentation / examples
16+
- [ ] 🔧 Refactor / internal change
17+
18+
## Checklist
19+
20+
- [ ] Tests pass locally (`lazbuild tests/TestRunner.lpi` then run `TestRunner`)
21+
- [ ] Added/updated tests where it makes sense
22+
- [ ] Updated `CHANGELOG.md`
23+
- [ ] Updated docs in `docs/` if behavior or API changed
24+
- [ ] New units use `{$mode objfpc}{$H+}{$J-}` and filenames match unit casing

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
name: Build & Test (${{ matrix.os }})
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, windows-latest]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Install Lazarus + FPC
24+
uses: gcarreno/setup-lazarus@v3
25+
with:
26+
lazarus-version: stable
27+
28+
- name: Build package
29+
run: lazbuild package/lazarus/threadpool_fp.lpk
30+
31+
- name: Build test runner
32+
run: lazbuild tests/TestRunner.lpi
33+
34+
- name: Run tests
35+
shell: bash
36+
run: |
37+
if [ -f tests/TestRunner.exe ]; then
38+
./tests/TestRunner.exe -a -p --format=plain
39+
else
40+
./tests/TestRunner -a -p --format=plain
41+
fi
42+
43+
build-examples:
44+
name: Build examples (${{ matrix.os }})
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os: [ubuntu-latest, windows-latest]
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Install Lazarus + FPC
56+
uses: gcarreno/setup-lazarus@v3
57+
with:
58+
lazarus-version: stable
59+
60+
- name: Build all examples
61+
shell: bash
62+
run: |
63+
set -e
64+
for lpi in examples/*/*.lpi; do
65+
echo "==> Building $lpi"
66+
lazbuild "$lpi"
67+
done

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [0.6.0] - 2026-06-11
8+
9+
### Added
10+
11+
- GitHub Actions CI (`.github/workflows/ci.yml`) — builds the package, runs the FPCUnit test suite, and builds all examples on both Linux and Windows for every push and pull request
12+
- `CONTRIBUTING.md` — build/test instructions, code style guide (including the unit-filename casing rule), and pull-request workflow
13+
- Issue templates (`.github/ISSUE_TEMPLATE/`) for bug reports and feature requests, plus a discussions contact link
14+
- Pull request template (`.github/PULL_REQUEST_TEMPLATE.md`)
15+
- README: Contributing section linking to `CONTRIBUTING.md`
16+
17+
### Changed
18+
19+
- Renamed source files to match their `unit` identifier casing so the library compiles on case-sensitive filesystems (Linux): `threadpool.simple.pas``ThreadPool.Simple.pas`, `threadpool.producerconsumer.pas``ThreadPool.ProducerConsumer.pas`, and `tests/threadpool.producerconsumer.tests.pas``tests/ThreadPool.ProducerConsumer.Tests.pas`
20+
- Normalized the unit reference in `tests/TestRunner.lpr` (`Threadpool.``ThreadPool.`)
21+
- README: replaced the hardcoded test-count badge with a live CI status badge
22+
23+
### Fixed
24+
25+
- **Access violation on Linux at runtime (exit code 217).** The test runner and example programs were missing the `cthreads` unit, which Unix/Linux requires (as the first unit) for any program that creates threads. Without it, constructing the thread pool crashed in the worker/sync-object setup. Added `{$IFDEF UNIX}cthreads{$ENDIF}` to `tests/TestRunner.lpr` and all 8 example programs. Windows was unaffected and did not need it
26+
- `ThreadPool.Simple` now compiles on non-Windows targets: the `IWorkerThread` methods (`QueryInterface`/`_AddRef`/`_Release`) hardcoded the `stdcall` calling convention, which only matches `IInterface` on Windows — FPC uses `cdecl` elsewhere. Guarded with `{$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF}`
27+
- `TSimpleWorkerThread` is now explicitly non-ref-counted (`_AddRef`/`_Release` return `-1`, the `TComponent` contract), so an `IWorkerThread` interface assignment can never free a worker the pool still owns via `ClearThreads`. Removed the now-unused `FRefCount` field
28+
- `TSimpleThreadPool.Destroy` is now safe to call on a partially constructed pool: it skips `WaitForAll` and the queue/thread cleanup when the relevant fields are `nil`, instead of dereferencing them
29+
- Example projects (all except `Starter`) only had the `src` search path in their `Release` build mode, so `lazbuild` (which builds the `Default` mode) could not find the units. Added the search path to each project's global compiler options
30+
- Tests `Test04_CreateDestroy` and `Test11_ThreadCount` hardcoded thread-count expectations that only held on multi-core machines; on low-core CI runners the enforced minimum of 4 threads made them fail. They now assert against the actual `Max(Min(requested, 2×ProcessorCount), 4)` formula
31+
- `Test08_QueueFullBehavior` assumed a single worker drains the queue, but the pool enforces a 4-thread minimum, so on Linux the queue drained before it could overflow. It now bursts `ThreadCount + QueueSize + 1` long-running tasks, which overflows a fixed queue deterministically regardless of core count or scheduling
32+
733
## [0.5.0] - 2026-04-13
834

935
### Added

CONTRIBUTING.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Contributing to ThreadPool for Free Pascal
2+
3+
Thanks for your interest in improving this library! Contributions of all
4+
sizes are welcome — bug reports, documentation fixes, new examples, and code.
5+
6+
## Ways to contribute
7+
8+
- 🐛 **Report a bug** — open an [issue](https://github.com/ikelaiah/threadpool-fp/issues) using the Bug Report template.
9+
- 💡 **Request a feature** — open an issue using the Feature Request template.
10+
- 📝 **Improve docs or examples** — these are especially appreciated and easy to start with.
11+
- 🔧 **Fix a bug or add a feature** — see the workflow below.
12+
13+
## Prerequisites
14+
15+
- Free Pascal 3.2.2 or later
16+
- Lazarus 3.6.0 or later (provides `lazbuild`)
17+
- No external dependencies
18+
19+
## Building
20+
21+
Build the package:
22+
23+
```bash
24+
lazbuild package/lazarus/threadpool_fp.lpk
25+
```
26+
27+
Or compile a single example directly with FPC:
28+
29+
```bash
30+
fpc -Fu./src examples/SimpleDemo/SimpleDemo.lpr
31+
```
32+
33+
## Running the tests
34+
35+
```bash
36+
lazbuild tests/TestRunner.lpi
37+
# Windows
38+
./tests/TestRunner.exe -a -p --format=plain
39+
# Linux / macOS
40+
./tests/TestRunner -a -p --format=plain
41+
```
42+
43+
All tests should pass before you submit a change. The full suite can take a
44+
few minutes to run because some tests exercise high task volumes.
45+
46+
CI runs the package build, the test suite, and all examples on Linux and
47+
Windows for every pull request — please make sure your branch is green.
48+
49+
## Code style
50+
51+
- Use `{$mode objfpc}{$H+}{$J-}` at the top of new units and programs.
52+
- Match the existing formatting: two-space indentation, `PascalCase` for
53+
types/methods, and a descriptive comment for non-obvious logic.
54+
- **Filenames must match the `unit` identifier's casing exactly**
55+
(e.g. unit `ThreadPool.Simple` lives in `ThreadPool.Simple.pas`). This keeps
56+
the library compiling on case-sensitive filesystems like Linux.
57+
- Keep the library dependency-free (FCL only).
58+
59+
## Pull request workflow
60+
61+
1. Fork the repo and create a branch off `main`
62+
(e.g. `feat/adaptive-threads` or `fix/queue-overflow`).
63+
2. Make your change, including tests and/or an example where it makes sense.
64+
3. Run the test suite locally and make sure it passes.
65+
4. Update `CHANGELOG.md` and any relevant docs in `docs/`.
66+
5. Open a pull request describing **what** changed and **why**.
67+
68+
## Reporting security issues
69+
70+
For anything sensitive, please email the maintainer rather than opening a
71+
public issue.
72+
73+
Thank you for helping make this library better! 🙏

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# 🚀 ThreadPool for Free Pascal
22

3-
[![Version](https://img.shields.io/badge/version-0.5.0-8B5CF6.svg)](CHANGELOG.md)
3+
[![Version](https://img.shields.io/badge/version-0.6.0-8B5CF6.svg)](CHANGELOG.md)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-1E3A8A.svg)](https://opensource.org/licenses/MIT)
55
[![Free Pascal](https://img.shields.io/badge/Free%20Pascal-3.2.2+-3B82F6.svg)](https://www.freepascal.org/)
66
[![Lazarus](https://img.shields.io/badge/Lazarus-4.0+-60A5FA.svg)](https://www.lazarus-ide.org/)
77
![Supports Windows](https://img.shields.io/badge/support-Windows-F59E0B?logo=Windows)
88
![Supports Linux](https://img.shields.io/badge/support-Linux-F59E0B?logo=Linux)
99
![No Dependencies](https://img.shields.io/badge/dependencies-none-10B981.svg)
10-
![Tests](https://img.shields.io/badge/tests-35%20passed-10B981.svg)
10+
[![CI](https://github.com/ikelaiah/threadpool-fp/actions/workflows/ci.yml/badge.svg)](https://github.com/ikelaiah/threadpool-fp/actions/workflows/ci.yml)
1111
[![Documentation](https://img.shields.io/badge/Docs-Available-brightgreen.svg)](docs/)
1212
[![Status](https://img.shields.io/badge/Status-Stable-10B981.svg)](README.md)
1313

@@ -522,6 +522,11 @@ GlobalThreadPool.WaitForAll;
522522
- More comprehensive tests
523523
- More examples
524524

525+
## 🤝 Contributing
526+
527+
Contributions are welcome — bug reports, docs, examples, and code. See
528+
[CONTRIBUTING.md](CONTRIBUTING.md) for how to build, test, and submit changes.
529+
525530
## 👏 Acknowledgments
526531

527532
Special thanks to the Free Pascal and Lazarus communities and the creators of the threading libraries mentioned above for inspiration!

0 commit comments

Comments
 (0)