ahamlabs / ahamlabs/toolB

[Refactor] Port Core Kernel to C++17 for Reactor Pattern & Service State Management

オープン
#35 コメント 0 件 リアクション 0 件 担当者 1 名 @psypherion が担当を希望しています GitHub で見る
enhancement
主要言語
C
スター
0
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

🚀 Context & Motivation
To evolve toolB from a raw concurrent server into a comprehensive Middleware Kernel, we need to implement complex state management features (Rate Limiting maps, Auth caches) and a more robust I/O model (Reactor Pattern/Epoll).

While C is performant, it lacks the standard containers and RAII (Resource Acquisition Is Initialization) semantics required to implement these features safely and maintainably. We are migrating the heartware_server to Systems C++ (C++17).

This is not a move to heavy object-oriented programming. We will adhere to a "Flat C++" style:

Using std:: containers for internal state.

Using RAII for resource management (Sockets, FD closure).

Keeping the Shared Memory boundary strictly C-compatible (POD types).

🎯 Objectives
1. Enable Complex State: Allow usage of std::unordered_map for O(1) IP tracking and Rate Limiting.

2. Safety & Cleanup: Replace manual close()/free() calls with RAII wrappers to prevent file descriptor leaks in the future Event Loop.

3. Prepare for Reactor: Establish the foundation for the transition from "Thread-per-Connection" to "Epoll/Event Loop".

🛠 Implementation Tasks

- [ ] Build System Update
- [ ] Update Makefile to use g++ (or clang++) instead of gcc.
- [ ] Set standard flags: -std=c++17 -O3 -Wall -pthread.
- [ ] File Migration
- [ ] Rename src/heartware_server.c → src/heartware_server.cpp.
- [ ] Rename src/c_parser.c → src/c_parser.cpp.
- [ ] SHM Compatibility Layer
- [ ] Wrap toolb_shm.h contents in extern "C" { ... } blocks.
- [ ] CRITICAL: Ensure all Shared Memory structs remain POD (Plain Old Data) types. Do not use std::string or std::vector inside the SHM structs, as this will break Python ctypes compatibility.
- [ ] Code Modernization (Phase 1)
- [ ] Replace malloc/free with new/delete or smart pointers (std::unique_ptr) for internal heap allocations.
- [ ] Create a basic Connection class wrapper to handle socket closing automatically on destruction.
- [ ] ⚠️ Constraints
- [ ] Zero-Copy Logic: The core ring buffer logic must remain pointer-based arithmetic to ensure zero-copy performance.
- [ ] Python Compatibility: No changes should be required on the Python side (toolb_shm_structs.py) during this refactor. The memory layout must remain identical.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。