C++20 lock-free thread pool & MPSC ring buffer library with cache-aligned task processing
      TLDR
libthreadable is a C++ library for cache-aware, concurrent task execution using
a thread pool with lock-free queues. It simplifies parallel programming by managing
threads and task distribution for performance-critical applications.
Example
#include <threadable/pool.hxx>
int main() {
  // thread pool:
  auto  pool  = fho::pool();
  auto& queue = pool.create();
  auto  token = queue.emplace_back( []() { cout << "task executed!\n"; });
  token.wait();
  // generic ring buffer:
  auto ring = fho::ring_buffer<int>();
  ring.emplace_back(1);
  ring.emplace_back(2);
  ring.emplace_back(3);
  assert(ring.size() == 3);
  for (auto v : ring)
  {
    cout << format("{}\n", v); // prints 1 2 3
  }
  assert(ring.size() == 3);
  while (auto v = ring.try_pop_front())
  {
    cout << format("{}\n", *v); // prints 1 2 3
  }
  assert(ring.size() == 0);
  return 0;
}
Design Overview
Thread Pool (pool) + Worker Threads (executor):
Manages multiple task queues and worker threads,
orchestrating task distribution to executors running
in dedicated threads via a scheduler.
task Queues (ring_buffer):
Lock-free multi-producer, multi-consumer ring buffer
to store tasks.
Ring Iterator (ring_iterator) + Slot (ring_slot):
Support the ring_buffer with efficient random access
and state management for buffer elements.
 
      
      
      Tests
      
      Benchmarks
      
      Reviews
      
      Builds
      
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-w64-mingw32 | 
            
            
              | tgt config | 
              windows_10-gcc_13.2_mingw_w64-static_O2 | 
            
            
              | timestamp | 
              2025-11-02 14:14:19 UTC (01 15:44:43 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-w64-mingw32 | 
            
            
              | tgt config | 
              windows_10-gcc_13.2_mingw_w64-O2 | 
            
            
              | timestamp | 
              2025-11-02 14:14:07 UTC (01 15:44:54 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-w64-mingw32 | 
            
            
              | tgt config | 
              windows_10-gcc_13.2_mingw_w64 | 
            
            
              | timestamp | 
              2025-11-02 14:13:49 UTC (01 15:45:13 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-clang_18_llvm_msvc_17.10-static_O2 | 
            
            
              | timestamp | 
              2025-11-02 14:13:34 UTC (01 15:45:28 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14-static_O3 | 
            
            
              | timestamp | 
              2025-11-02 14:13:31 UTC (01 15:45:31 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-clang_18_llvm_msvc_17.10-O2 | 
            
            
              | timestamp | 
              2025-11-02 14:13:08 UTC (01 15:45:54 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-clang_18_llvm_msvc_17.10 | 
            
            
              | timestamp | 
              2025-11-02 14:12:42 UTC (01 15:46:19 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-clang_17_msvc_msvc_17.10 | 
            
            
              | timestamp | 
              2025-11-02 14:12:29 UTC (01 15:46:33 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14-ndebug_O3 | 
            
            
              | timestamp | 
              2025-11-02 14:12:16 UTC (01 15:46:45 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_fedora_40-gcc_14-bindist | 
            
            
              | timestamp | 
              2025-11-02 14:12:00 UTC (01 15:47:02 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14-O3 | 
            
            
              | timestamp | 
              2025-11-02 14:11:57 UTC (01 15:47:05 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_12-bindist | 
            
            
              | timestamp | 
              2025-11-02 14:11:47 UTC (01 15:47:15 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-freebsd14.1 | 
            
            
              | tgt config | 
              freebsd_14-clang_18-static_O3 | 
            
            
              | timestamp | 
              2025-11-02 14:11:45 UTC (01 15:47:17 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_ubuntu_24.04-gcc_13-bindist | 
            
            
              | timestamp | 
              2025-11-02 14:11:35 UTC (01 15:47:27 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14 | 
            
            
              | timestamp | 
              2025-11-02 14:11:18 UTC (01 15:47:44 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_17 | 
            
            
              | timestamp | 
              2025-11-02 14:11:06 UTC (01 15:47:56 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-freebsd14.1 | 
            
            
              | tgt config | 
              freebsd_14-clang_18-O3 | 
            
            
              | timestamp | 
              2025-11-02 14:10:58 UTC (01 15:48:04 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_13.1 | 
            
            
              | timestamp | 
              2025-11-02 14:10:33 UTC (01 15:48:29 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-freebsd13.3 | 
            
            
              | tgt config | 
              freebsd_13-clang_17 | 
            
            
              | timestamp | 
              2025-11-02 14:10:21 UTC (01 15:48:41 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-freebsd14.1 | 
            
            
              | tgt config | 
              freebsd_14-clang_18 | 
            
            
              | timestamp | 
              2025-11-02 14:10:19 UTC (01 15:48:43 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_17_libc++ | 
            
            
              | timestamp | 
              2025-11-02 14:09:56 UTC (01 15:49:06 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18_libc++-O3 | 
            
            
              | timestamp | 
              2025-11-02 13:54:50 UTC (01 16:04:12 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18_libc++ | 
            
            
              | timestamp | 
              2025-11-02 13:54:12 UTC (01 16:04:50 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18-static_O3 | 
            
            
              | timestamp | 
              2025-11-02 13:54:06 UTC (01 16:04:56 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18-O3 | 
            
            
              | timestamp | 
              2025-11-02 13:53:23 UTC (01 16:05:39 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18 | 
            
            
              | timestamp | 
              2025-11-02 13:52:58 UTC (01 16:06:03 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_17_libc++ | 
            
            
              | timestamp | 
              2025-11-02 11:15:44 UTC (01 18:43:17 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_13 | 
            
            
              | timestamp | 
              2025-11-02 11:15:10 UTC (01 18:43:52 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_17 | 
            
            
              | timestamp | 
              2025-11-02 11:15:05 UTC (01 18:43:57 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-msvc_17.8-static_O2 | 
            
            
              | timestamp | 
              2025-11-02 11:09:20 UTC (01 18:49:42 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-msvc_17.10-static_O2 | 
            
            
              | timestamp | 
              2025-11-02 11:09:03 UTC (01 18:49:59 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-msvc_17.8-O2 | 
            
            
              | timestamp | 
              2025-11-02 11:08:06 UTC (01 18:50:56 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-msvc_17.10-O2 | 
            
            
              | timestamp | 
              2025-11-02 11:07:58 UTC (01 18:51:03 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-msvc_17.10 | 
            
            
              | timestamp | 
              2025-11-02 11:07:09 UTC (01 18:51:52 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-microsoft-win32-msvc14.3 | 
            
            
              | tgt config | 
              windows_10-msvc_17.8 | 
            
            
              | timestamp | 
              2025-11-02 11:06:50 UTC (01 18:52:12 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18_libc++-static_O3 | 
            
            
              | timestamp | 
              2025-11-02 11:03:26 UTC (01 18:55:36 days ago) | 
            
            
              | result | 
              error (test) | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14-static_O3 | 
            
            
              | timestamp | 
              2025-10-31 02:30:11 UTC (04 03:28:51 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14-ndebug_O3 | 
            
            
              | timestamp | 
              2025-10-31 02:28:28 UTC (04 03:30:34 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14-O3 | 
            
            
              | timestamp | 
              2025-10-31 02:27:49 UTC (04 03:31:13 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              aarch64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-gcc_14 | 
            
            
              | timestamp | 
              2025-10-31 02:26:05 UTC (04 03:32:56 days ago) | 
            
            
              | result | 
              success | log | rebuild | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18-O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18-static_O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18_libc++ | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18_libc++-O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_debian_12-clang_18_libc++-static_O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-linux-gnu | 
            
            
              | tgt config | 
              linux_fedora_39-gcc_13-bindist | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin22.5.0 | 
            
            
              | tgt config | 
              macos_13-clang_15.0 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin23.5.0 | 
            
            
              | tgt config | 
              macos_14-clang_15.0 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin23.5.0 | 
            
            
              | tgt config | 
              macos_14-clang_15.0-O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin23.5.0 | 
            
            
              | tgt config | 
              macos_14-clang_15.0-static_O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin23.5.0 | 
            
            
              | tgt config | 
              macos_14-gcc_14_homebrew | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin23.5.0 | 
            
            
              | tgt config | 
              macos_14-gcc_14_homebrew-O3 | 
            
            
              | result | 
              unbuilt | 
            
          
        
        
          
            
              | toolchain | 
              public-0.17.0 | 
            
            
              | target | 
              x86_64-apple-darwin23.5.0 | 
            
            
              | tgt config | 
              macos_14-gcc_14_homebrew-static_O3 | 
            
            
              | result | 
              unbuilt |