Skip to content

feat(threading): implement Job System with work-stealing thread pool …#47

Merged
LyeZinho merged 1 commit intomainfrom
10-job-system-worker-threads
Apr 14, 2026
Merged

feat(threading): implement Job System with work-stealing thread pool …#47
LyeZinho merged 1 commit intomainfrom
10-job-system-worker-threads

Conversation

@LyeZinho
Copy link
Copy Markdown
Member

…(RF2.2-RF2.6)

Work-stealing thread pool with per-worker deques, 3 priority levels (Critical/Normal/Background), JobHandle index+version tracking, JobBarrier group synchronization, and scheduleParallelFor.

  • JobPriority enum with Critical > Normal > Background ordering
  • IJob virtual interface + JobWithData type-safe zero-alloc jobs
  • JobHandle with atomic completion flag (index+version avoids ABA)
  • JobBarrier with condition_variable for group wait
  • JobSystem: N-1 worker threads, priority-ordered execution, work-stealing from other workers when idle
  • scheduleData convenience template
  • scheduleParallelFor chunked across workers
  • waitAll with condition_variable notification
  • Stats tracking (active workers, pending, completed, avg time)
  • 41 tests, 1054 assertions (incl. 10K/100K stress tests)

File Description
src/threading/JobSystem.hpp Caffeine::Threading — JobPriority, IJob, JobWithData, JobHandle (index+version), JobBarrier, JobSystem class with work-stealing
src/threading/JobSystem.cpp Thread pool (N-1 workers), priority-ordered execution (Critical→Normal→Background), work-stealing from other workers, condition_variable sleep/wake, stats tracking
tests/test_jobsystem.cpp 41 tests, 1054 assertions — priority enum, IJob/JobWithData, JobHandle, JobBarrier, scheduling, scheduleData, parallelFor, waitAll, stats, stress tests (1K, 10K, 100K jobs), priority starvation test
CMakeLists.txt Added src/threading/JobSystem.cpp to lib sources
tests/CMakeLists.txt Added test_jobsystem.cpp

…(RF2.2-RF2.6)

Work-stealing thread pool with per-worker deques, 3 priority levels
(Critical/Normal/Background), JobHandle index+version tracking,
JobBarrier group synchronization, and scheduleParallelFor.

- JobPriority enum with Critical > Normal > Background ordering
- IJob virtual interface + JobWithData<T> type-safe zero-alloc jobs
- JobHandle with atomic completion flag (index+version avoids ABA)
- JobBarrier with condition_variable for group wait
- JobSystem: N-1 worker threads, priority-ordered execution,
  work-stealing from other workers when idle
- scheduleData<T> convenience template
- scheduleParallelFor chunked across workers
- waitAll with condition_variable notification
- Stats tracking (active workers, pending, completed, avg time)
- 41 tests, 1054 assertions (incl. 10K/100K stress tests)
@LyeZinho LyeZinho linked an issue Apr 14, 2026 that may be closed by this pull request
5 tasks
@LyeZinho LyeZinho added documentation Improvements or additions to documentation enhancement New feature or request planned-implementation Implementations planned according with roadmap labels Apr 14, 2026
@LyeZinho LyeZinho added this to the phase 2 milestone Apr 14, 2026
@LyeZinho LyeZinho requested a review from Copilot April 14, 2026 15:22
@LyeZinho LyeZinho merged commit 34e9cc8 into main Apr 14, 2026
3 checks passed
@LyeZinho LyeZinho review requested due to automatic review settings April 14, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request planned-implementation Implementations planned according with roadmap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Job System (Worker Threads)

2 participants