28#define TEST(name) void test_##name()
29#define RUN_TEST(name) \
31 std::cout << "Running test: " << #name << " ... "; \
34 std::cout << "PASSED\n"; \
36 } catch (const std::exception& e) { \
37 std::cout << "FAILED: " << e.what() << "\n"; \
42#define ASSERT_TRUE(condition) \
44 throw std::runtime_error("Assertion failed: " #condition); \
47#define ASSERT_FALSE(condition) ASSERT_TRUE(!(condition))
54TEST(configuration_construction) {
58 config.
pool_type = thread_pool_type::standard;
67TEST(adapter_construction) {
78TEST(api_availability_submit) {
88 if (init_result.is_ok()) {
89 std::atomic<bool> executed{
false};
91 auto future = adapter.
submit([&executed]() {
97 auto value = future.get();
107TEST(api_availability_priority) {
116 if (init_result.is_ok()) {
117 std::atomic<bool> executed{
false};
121 auto future = adapter.
submit([&executed]() {
175 if (init_result.is_ok()) {
192 if (init_result.is_ok()) {
194 auto future = adapter.
submit([]() {
return 1; });
243 std::cout <<
"=== Thread Adapter API Tests (Phase 4) ===\n";
244 std::cout <<
"Note: These tests verify API availability and basic functionality.\n";
245 std::cout <<
"Some tests may be skipped if thread_system is not available.\n\n";
247 RUN_TEST(configuration_construction);
250 RUN_TEST(api_availability_priority);
258 std::cout <<
"\n=== Test Summary ===\n";
263 std::cout <<
"=== All tests passed! ✓ ===\n";
266 std::cout <<
"=== Some tests failed! ✗ ===\n";
Thread pool adapter for async database operations.
auto submit(F &&f, Args &&... args) -> std::future< std::invoke_result_t< F, Args... > >
Submit a task and get a future.
common::VoidResult shutdown()
Shutdown thread pool gracefully.
common::VoidResult initialize()
Initialize thread pool.
std::size_t queue_size() const
Get current queue size.
std::size_t worker_count() const
Get number of worker threads.
Thread pool configuration for async operations.
thread_pool_type pool_type
Thread pool implementation type.
bool enable_priority_scheduling
Enable priority-based task scheduling.
std::size_t max_queue_size
Maximum queued tasks (0 = unlimited)
std::size_t thread_count
Number of worker threads (0 = auto-detect from hardware)
#define ASSERT_TRUE(condition)
Thread pool adapter with runtime backend selection.