Skip to main content

Use of C++

Language standard​

The entire codebase is C++17 compliant. Several features from C++20 and later are adopted ahead of the standard, either through in-house implementations or vendored single-header libraries.

The table below lists every in-house implementation and every vendored library, and what each provides:

Feature / libraryIn-house or external
Coroutines (async_task, CORO_* macros)In-house - custom C++17 stackless coroutine framework
span<T>In-house - contiguous view type
flat_map<K, V>In-house - sorted-vector associative container
Executor and strand frameworkIn-house - task_executor, strand_executor, priority strands
SIMD abstractionIn-house - architecture-portable wrapper over SSE/AVX/NEON intrinsics
Memory pools and object poolsIn-house - fixed-size, lock-free allocators for real-time paths
Custom containersIn-house - ring buffers, static vectors, concurrent queues built on the primitives below
ASN.1 code generatorIn-house - generates strongly-typed C++ from 3GPP ASN.1 schemas
expected<T, E>External: TartanLlama/expected - C++23 std::expected backport; re-exported as ocudu::expected
String formattingExternal: fmt - C++20 std::format backport; used directly as fmt::format
Lock-free MPMC queueExternal: cameron314/concurrentqueue
Lock-free MPMC / SPSC queuesExternal: rigtorp/MPMCQueue + SPSCQueue
JSON serialisationExternal: nlohmann/json
CLI argument parsingExternal: CLI11
WebSocket serverExternal: uWebSockets
Stack traces (debug builds)External: Backward-cpp

STL and specialised containers​

Heavy use of the STL is encouraged. Where the STL does not meet real-time or performance requirements, OCUDU provides its own specialised containers - or wraps the vendored lock-free queue libraries listed above:

  • Lock-free and priority queues (backed by cameron314 and rigtorp primitives)
  • Memory pools and fixed-size allocators
  • Unique and shared object pools
  • Custom vectors (static_vector) and ring buffers

ASN.1 generator​

3GPP protocols define message formats in ASN.1. OCUDU uses its own ASN.1 generator that translates ASN.1 syntax directly into strongly-typed C++ types, eliminating manual serialisation code and reducing the risk of protocol encoding errors. The generator is not open-sourced yet.

Asynchronous programming with coroutines​

Protocol procedures often involve waiting for responses from peer entities or lower layers. OCUDU uses a custom C++17 coroutine framework (not C++20 language coroutines) to express these asynchronous sequences as straightforward, sequential-looking code rather than callback chains or explicit state machines. See Asynchronous Programming for a full description.

Executors​

OCUDU abstracts the execution model through an executor framework so that business logic does not depend on how threads are managed. The same protocol code can run on a single-core embedded system, a multi-socket server, or a cloud VM by changing only configuration, not source code.

Executor typeDescription
Single workerOne dedicated thread, single-priority queue
Thread poolMultiple workers sharing a task queue
Multi-priority thread poolWorkers with high/low priority lanes
StrandSerialises tasks on top of a worker or pool; single and multi-priority variants
Fork limiterCaps the degree of parallelism for bounded-concurrency tasks

SIMD abstraction​

An abstraction layer wraps architecture-specific SIMD intrinsics (SSE, AVX2/512, NEON). Inner-layer algorithm code calls the abstraction; the correct instruction set is selected at compile time or runtime without changes to the algorithm implementation.