Skip to content

[REFACTOR] Simplify typed_pool template hierarchy - Simple Design compliance #354

Description

@kcenon

Summary

Evaluate and simplify the typed_pool template hierarchy to reduce complexity while maintaining type safety, following Simple Design principle of "Fewest Elements".

Current State

Parallel class hierarchies exist:

Standard Pool Typed Pool
thread_pool typed_thread_pool_t<JobType>
thread_worker typed_thread_worker_t<JobType>
job typed_job_t<JobType>
job_queue typed_job_queue_t<JobType>

Directory: /include/kcenon/thread/impl/typed_pool/ contains 10+ template files

Problem Analysis

  • Entire parallel hierarchy for type-safe pooling
  • Increases codebase complexity significantly
  • May be over-engineered for use cases
  • Violates "Fewest Elements" principle

Analysis Tasks

  • Document actual usage of typed_pool in dependent projects
  • Measure performance difference vs runtime polymorphism
  • Evaluate if templates add significant compile-time benefits
  • Consider CRTP or policy-based design as alternative

Potential Simplifications

Option A: Keep but document

  • If typed_pool provides measurable benefits, document use cases clearly
  • Add usage examples in docs/

Option B: Merge with base classes

  • Use template specialization on base classes
  • Reduce from 2 hierarchies to 1

Option C: Remove typed_pool

  • If usage is minimal, deprecate and remove
  • Guide users to standard pool with std::any

Acceptance Criteria

  • Decision documented with rationale
  • If keeping: clear documentation on when to use
  • If simplifying: migration path documented
  • Code complexity reduced or justified

Notes

This issue requires analysis before implementation. May result in "no change" if typed_pool provides significant value.

Metadata

Metadata

Assignees

Labels

priority:lowLow priority issuerefactoringCode refactoring and improvements

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions