| doc_id | THR-MIGR-003 |
|---|---|
| doc_title | Thread System Migration Guide |
| doc_version | 1.0.0 |
| doc_date | 2026-04-04 |
| doc_status | Released |
| project | thread_system |
| category | MIGR |
SSOT: This document is the single source of truth for Thread System Migration Guide.
Language: English | 한국어
- v1.0.0 API Freeze (current)
- v3.0.0 Migration (common_system)
- Overview
- Migration Status
- Breaking Changes
- Migration Instructions for Users
- Timeline
Release Date: 2026-04-14
v1.0.0 is an API stability commitment. From v1.0.0 onward, any breaking change to the public API requires a major version bump. This section records the surface that was frozen and the legacy APIs that remain only for migration support.
The authoritative public headers live under include/kcenon/thread/:
| Subsystem | Path | Notes |
|---|---|---|
| Core threading | core/ |
thread_pool, thread_worker, job, job_queue, cancellation_token, future_job, submit_options |
| Queues | queue/, concurrent/ |
adaptive_job_queue, concurrent_queue, queue_factory |
| DAG | dag/ |
dag_scheduler, dag_job, dag_job_builder |
| Configuration | thread_config.h, config/ |
Unified builder for pool, DAG, and aging settings |
| Error handling | core/error_handling.h |
error_code enum + common::Result<T> / common::VoidResult helpers |
| Synchronization | core/sync_primitives.h, core/hazard_pointer.h |
Lock-free reclamation helpers |
The following APIs emit compiler warnings in v1.0.0 and will be removed in v2.0.0.
| Symbol | Replacement | Trigger |
|---|---|---|
thread_system:: / thread_module:: / thread_namespace:: namespace aliases |
Use kcenon::thread:: directly |
#pragma message on compatibility.h include |
utility_module:: namespace alias |
Use kcenon::thread::utils:: directly |
#pragma message on compatibility.h include |
kcenon::thread::log_level (enum in thread_logger.h) |
kcenon::thread::log_level_v2 or common::interfaces::log_level |
Warnings via the deprecated thread_logger methods that consume it |
kcenon::thread::thread_logger::log(), log_error(), set_enabled(), is_enabled(), set_level(), set_lightweight_mode(), is_lightweight_mode() |
thread_context::log() with common::interfaces::ILogger |
[[deprecated]] attribute |
<kcenon/thread/lockfree/lockfree_queue.h> (forwarding header) |
<kcenon/thread/concurrent/concurrent_queue.h> |
#pragma message on include |
<kcenon/thread/core/thread_pool_fmt.h> (forwarding header) |
<kcenon/thread/formatters.h> |
#pragma message on include (pre-existing) |
<kcenon/thread/dag/dag_config.h> (documentation-only deprecation) |
<kcenon/thread/thread_config.h> builder |
Doxygen @deprecated |
<kcenon/thread/impl/typed_pool/priority_aging_config.h> (documentation-only deprecation) |
<kcenon/thread/thread_config.h> builder |
Doxygen @deprecated |
While migrating a dependent project, warnings emitted by legacy headers can be
silenced by defining the following macros before the #include:
// Legacy namespace aliases in compatibility.h
#define THREAD_SUPPRESS_LEGACY_NAMESPACE_WARNING 1
#include <kcenon/thread/compatibility.h>
// Legacy forwarding header lockfree_queue.h
#define THREAD_SUPPRESS_LEGACY_LOCKFREE_QUEUE_WARNING 1
#include <kcenon/thread/lockfree/lockfree_queue.h>These macros must be removed before v2.0.0 adoption.
cancellation_token::check_cancelled()returnscommon::VoidResult(previouslythrow_if_cancelled()threwstd::runtime_error). See #671.cancellable_future<T>::get()/get_for()returncommon::Result<T>/common::Result<std::optional<T>>. See #671.thread_pool::submit_wait_any()returnscommon::Result<R>witherror_code::invalid_argumentfor empty input. See #671.
Previously removed in v3.0.0 (kept for reference):
kcenon::thread::result<T>/result_void/error— usecommon::Result<T>/common::VoidResult/common::error_info.kcenon::thread::logger_interface/monitoring_interface/monitorable_interface— usecommon::interfaces::ILogger/IMonitor/IMonitorable.kcenon::thread::throw_if_cancelled()— removed in #671, replaced bycheck_cancelled()returningcommon::VoidResult.
Release Date: 2025-12-19
v3.0.0 completes the migration to common_system-only public contracts. This is a breaking change release.
| Legacy Type | Replacement |
|---|---|
kcenon::thread::result<T> |
kcenon::common::Result<T> |
kcenon::thread::result_void |
kcenon::common::VoidResult |
kcenon::thread::error |
kcenon::common::error_info |
kcenon::thread::logger_interface |
kcenon::common::interfaces::ILogger |
kcenon::thread::log_level |
kcenon::common::log_level |
kcenon::thread::monitoring_interface |
kcenon::common::interfaces::IMonitor |
kcenon::thread::monitorable_interface |
kcenon::common::interfaces::IMonitorable |
kcenon::shared::* |
kcenon::common::interfaces::IExecutor |
// Error handling
// Before:
#include <kcenon/thread/core/error_handling.h>
kcenon::thread::result<int> foo();
// After:
#include <kcenon/common/result.h>
kcenon::common::Result<int> foo();
// API changes:
// .has_error() → .is_err()
// .get_error() → .error()
// .value() → .value() (unchanged)This document tracks the migration of the thread_system from a monolithic architecture to a modular ecosystem.
Completed Tasks:
- Verified existing interfaces (
logger_interface.h,monitoring_interface.h) are properly isolated - Updated
thread_context.hto support multi-pool monitoring with overloaded methods - Fixed initialization order warnings in
thread_pool.cppandthread_worker.cpp - Updated sample code to use correct API signatures
- Fixed namespace conflicts in
multi_process_monitoring_integrationsample - All tests passing successfully
Key Changes:
-
Added overloaded
update_thread_pool_metricsmethod inthread_context.h:void update_thread_pool_metrics(const std::string& pool_name, std::uint32_t pool_instance_id, const monitoring_interface::thread_pool_metrics& metrics)
-
Fixed constructor initialization order in:
thread_pool.cpp: Reordered to match member declaration orderthread_worker.cpp: Reordered to match member declaration order
-
Updated sample code:
- Fixed
callback_jobconstructor parameter order (callback first, then name) - Updated to use new
thread_pool::start()API (no worker count parameter) - Fixed namespace resolution for monitoring interface types
- Fixed
Completed Tasks:
- Created modular directory structure under
modular_structure/ - Set up core module CMakeLists.txt with proper export configuration
- Created integration templates for logger and monitoring modules
- Prepared CMake package configuration for find_package support
- Documented integration patterns for optional modules
New Structure:
modular_structure/
├── core/ # Core thread_system module
│ ├── CMakeLists.txt # Main build configuration
│ ├── cmake/ # CMake config templates
│ ├── include/ # Public headers
│ └── src/ # Implementation files
└── optional/ # Integration templates
├── logger_integration/
└── monitoring_integration/
Key Features:
- Core module with zero external dependencies (except standard library)
- Clean CMake export configuration for easy integration
- Comprehensive integration guides for logger and monitoring
- Backward compatibility support via target aliases
Completed Tasks:
- ✅ Moved all core components to modular structure
- ✅ Updated all include paths to use thread_system_core namespace
- ✅ Fixed all compilation errors with automated scripts
- ✅ Successfully built core module as standalone library
- ✅ Created compatibility headers for backward compatibility
Key Changes:
-
Migrated components:
thread_base/- Core threading abstractionsthread_pool/- Standard thread pool implementationtyped_thread_pool/- Type-safe thread pool with prioritiesutilities/- String conversion and formatting utilitiesinterfaces/- Logger and monitoring interfaces
-
Include path updates:
- All internal includes now use
thread_system_core/prefix - Created Python scripts to automate include path fixes
- Fixed over 60 files with incorrect include paths
- All internal includes now use
-
Build system improvements:
- Core module builds with C++20 standard
- Added platform-specific support (iconv for macOS)
- C++20 std::format used exclusively (fmt library removed)
- Clean CMake export configuration
-
Compatibility:
- Created
.compatheaders for smooth migration - Original project still builds without changes
- All tests passing in both original and modular versions
- Created
Completed Tasks:
- ✅ Created comprehensive integration test suite
- ✅ Implemented tests for basic thread pool, logger, monitoring, and typed thread pool
- ✅ Created performance benchmarks
- ✅ Verified core module can be compiled and linked independently
- ✅ Identified integration issues with CMake config generation
Key Findings:
- Core module builds successfully as standalone library
- Job queue and job execution work correctly in isolation
- CMake config file generation has issues (EOF in config file)
- Thread pool worker initialization may need adjustment
- API signatures have evolved (callback_job requires result types)
Test Files Created:
test_basic_thread_pool.cpp- Basic thread pool functionalitytest_logger_integration.cpp- Custom logger implementation teststest_monitoring_integration.cpp- Custom monitoring implementation teststest_typed_thread_pool.cpp- Priority-based thread pool testsbenchmark_thread_system.cpp- Performance benchmarkssimple_test.cpp- Minimal integration testminimal_test.cpp- Direct job queue test
The project completed a structural migration and documentation pass:
- New source layout under core/, implementations/, interfaces/, utilities/
- CMake updated with per-module targets and an optional
docstarget (Doxygen) - Added public interfaces: executor_interface, scheduler_interface, monitorable_interface
- job_queue implements scheduler_interface; thread_pool and typed_thread_pool implement executor_interface
- Documentation added:
- docs/API_REFERENCE.md (complete API documentation with interfaces)
- docs/USER_GUIDE.md (build, usage, docs generation)
- Module READMEs in core/, implementations/, interfaces/
Action items for downstream integrations:
- Update include paths to the new module headers
- Link to the new library targets (thread_base, thread_pool, typed_thread_pool, lockfree, interfaces, utilities)
- Generate Doxygen docs via
cmake --build build --target docs(requires Doxygen)
Integration Patterns Verified:
- Custom logger implementation works with thread_context
- Custom monitoring implementation captures metrics correctly
- Job queue enqueue/dequeue operations function properly
- Module uses C++20 std::format exclusively (no external format library dependency)
Planned Tasks:
- Create migration guide for users
- Release alpha/beta versions
- Gather feedback and iterate
- Final release with deprecation notices
thread_pool::start()no longer accepts worker count parametercallback_jobconstructor now takes callback first, then optional name- Namespace
monitoring_interfacecontains both namespace and class of same name - API consistency:
thread_poolmethods now returnresult_voidinstead ofstd::optional<std::string>- Updated signatures:
auto start() -> result_voidauto stop(bool immediately = false) -> result_voidauto enqueue(std::unique_ptr<job>&&) -> result_voidauto enqueue_batch(std::vector<std::unique_ptr<job>>&&) -> result_void
- Check errors via
has_error()and inspect withget_error().to_string()
- Updated signatures:
- Will require separate module dependencies in future phases
- Include paths will change from internal to external modules
New Feature: thread_pool now supports policy_queue through the adapter pattern.
#include <kcenon/thread/adapters/job_queue_adapter.h>
#include <kcenon/thread/adapters/policy_queue_adapter.h>
// Using job_queue_adapter (wraps existing job_queue)
auto adapter = std::make_unique<job_queue_adapter>();
auto pool = std::make_shared<thread_pool>("my_pool", std::move(adapter));
// Using make_standard_queue_adapter() helper
auto pool2 = std::make_shared<thread_pool>(
"pool2",
make_standard_queue_adapter());
// Using make_lockfree_queue_adapter() helper
auto pool3 = std::make_shared<thread_pool>(
"pool3",
make_lockfree_queue_adapter());All existing code continues to work without changes:
// Still works - default constructor
auto pool = std::make_shared<thread_pool>();
// Still works - custom job_queue
auto queue = std::make_shared<job_queue>();
auto pool = std::make_shared<thread_pool>("my_pool", queue);The pool_queue_adapter_interface provides a unified API for both queue types:
class pool_queue_adapter_interface {
public:
virtual auto enqueue(std::unique_ptr<job>&&) -> common::VoidResult = 0;
virtual auto enqueue_batch(std::vector<std::unique_ptr<job>>&&) -> common::VoidResult = 0;
virtual auto dequeue() -> common::Result<std::unique_ptr<job>> = 0;
virtual auto try_dequeue() -> common::Result<std::unique_ptr<job>> = 0;
virtual auto empty() const -> bool = 0;
virtual auto size() const -> std::size_t = 0;
virtual auto clear() -> void = 0;
virtual auto stop() -> void = 0;
virtual auto is_stopped() const -> bool = 0;
virtual auto get_capabilities() const -> queue_capabilities = 0;
virtual auto to_string() const -> std::string = 0;
virtual auto get_job_queue() const -> std::shared_ptr<job_queue> = 0;
virtual auto get_scheduler() -> scheduler_interface& = 0;
};- Workers with policy_queue: When using
policy_queue_adapterdirectly (not wrapping ajob_queue), workers currently require ajob_queuebackend. This limitation may be lifted in future versions whenthread_workeris updated to usescheduler_interface.
New Test Files: Comprehensive integration tests for policy_queue have been added.
| File | Description |
|---|---|
policy_queue_integration_test.cpp |
Tests standard_queue, policy_lockfree_queue, bounded queues |
queue_performance_comparison_test.cpp |
Performance benchmarks comparing legacy job_queue vs policy_queue |
- Basic queue operations (enqueue, dequeue, clear, stop)
- FIFO ordering verification
- Concurrent enqueue/dequeue with multiple threads
- Bounded queue overflow policies (reject, drop_oldest)
- Queue capabilities and scheduler interface compliance
- Single-threaded and multi-threaded throughput benchmarks
- Dequeue latency measurements
# Run policy_queue tests only
./bin/integration_tests --gtest_filter="PolicyQueue*"
# Run performance comparison tests
./bin/integration_tests --gtest_filter="QueuePerformance*"
# Run all integration tests
./bin/integration_tests| Test | Reason |
|---|---|
ThreadPoolWithStandardQueueAdapter |
policy_queue adapter requires job_queue backend for workers |
ThreadPoolWithLockfreeQueueAdapter |
Same limitation as above |
LockfreeQueueConcurrentOperations |
Potential issues in lockfree_sync_policy under high contention |
These limitations will be addressed in future updates when thread_worker is updated to use scheduler_interface directly.
No action required. All changes are backward compatible.
- Update CMake to use find_package for separate modules
- Update include paths for logger and monitoring
- Link against separate libraries instead of monolithic thread_system
- Phase 1: ✅ Complete (2025-01-27)
- Phase 2: ✅ Complete (2025-01-27)
- Phase 3: ✅ Complete (2025-01-27)
- Phase 4: ✅ Complete (2025-01-27)
- Phase 5: In Progress - Estimated 6 weeks
Total estimated completion: Q1 2025
The migration is complete with the modular structure in place and interfaces integrated across pools and queues. All documentation has been updated to reflect the current architecture. See details below.
The previously separate status document (MIGRATION_STATUS.md) has been merged into this section to keep migration guidance and current state together.
Last Updated: 2025-01-11