Areg SDK Examples
August 21, 2026 ยท View on GitHub
This document is part of the Areg SDK and describes its example projects.
Copyright (c) 2017-2026, Aregtech (Artak Avetyan)
Contact: info[at]areg.tech
Website: https://www.areg.tech
Introduction
The Areg SDK is a framework for building high-performance, real-time, and distributed applications. It excels in:
- ๐งต Multithreading โ Efficient handling of concurrent tasks within a single process.
- ๐ Multiprocessing / IPC โ Seamless inter-process communication across distributed systems.
- โ๏ธ Service Discovery & Fault-Tolerance โ Automatic service registration, recovery, and resilient operation.
- โฑ Event-Driven Architecture โ Real-time event handling with timers, state-machines, and worker threads.
This repository contains example projects illustrating Areg SDK capabilities. Each example provides practical insights into building scalable, robust, and efficient applications.
Quick Start โ Build & Run
Important
Requirements: Ensure you have CMake 3.20+ or MSVS 2019+. Ensure you have Java17+ on your machine for code generator.
- Clone the Repository
git clone https://github.com/aregtech/areg-sdk.git
cd areg-sdk
- Build with CMake
cmake -B ./build
cmake --build ./build -j 20
Note
By default, AREG_EXAMPLES is ON to include examples. For advanced build options, see Building Areg SDK with CMake.
- Build with Visual Studio
MSBuild ./areg-sdk.sln
Developer Notes
- IPC Projects: Multiprocessing examples require mtrouter for inter-process communication.
- Fault-Tolerance: Services work reliably regardless of startup order due to automatic discovery and recovery.
- Generated Projects: Projects with names
NN_generatedare created from Service Interface (.siml) documents during build. - Windows-only Projects: 20_winchat requires MFC and MSVC/ClangCL compilers.
Example Projects
| Project | Scope | Highlights | Key Feature / Solution |
|---|---|---|---|
| 01_minimalrpc | ๐งต Multithreading | Object RPC, Minimal Setup | Minimal thread-to-thread RPC with auto-discovery; provider handles request and signals app quit. |
| 02_minimalipc | ๐ Multiprocessing | IPC, Minimal Setup | Demonstrates minimal inter-process communication setup; illustrates message exchange across processes via mtrouter. |
| 03_helloservice | ๐ Multiprocessing | Service/Client, Threading Model | Introduces service creation and client-server interactions; flexible threading and process models for IPC. |
| 04_hellothread | ๐งต Multithreading | Thread Lifecycle | Demonstrates thread creation, management, and synchronization; prints "Hello World!" in a separate thread. |
| 05_buffer | ๐งต Multithreading | Shared Memory, Serialization | Shows how to serialize data into a shared buffer, pass it between threads, and deserialize it in another thread. |
| 06_file | ๐งต Multithreading | File Handling | Demonstrates reading, writing, copying, and deleting files in text and binary formats across threads. |
| 07_logging | ๐งต Multithreading | Logging, Tracing | Shows application method call tracing and message logging for debugging and runtime analysis. |
| 08_timer | ๐งต Multithreading | Timers, Real-Time Events | Demonstrates one-shot, periodic, and continuous timers for real-time event handling in threads. |
| 09_threads | ๐งต Multithreading | Event Dispatching, Threads | Illustrates creating custom event dispatching threads for real-time multithreaded applications. |
| 10_sync | ๐งต Multithreading | Mutex, Events | Demonstrates synchronization primitives (mutexes, events) for safe multithreaded operations. |
| 11_service | ๐งต Multithreading | Service Provider | Shows single-threaded service provider creation and deployment within an application model. |
| 12_svcmulti | ๐งต Multithreading | Service Reuse | Demonstrates service reuse across multiple threads and processes within an application model. |
| 13_locsvc | ๐งต Multithreading | Local Service | Introduces a local service; demonstrates Service Provider and Consumer communication in a single process. |
| 14_locmesh | ๐งต Multithreading | Service Mesh | Shows a mesh of local services communicating across multiple threads for real-time interactions. |
| 15_pubsvc | ๐ Multiprocessing | Public Service, IPC | Demonstrates a public service provider and client communication across processes using Object RPC. |
| 16_pubmesh | ๐ Multiprocessing | Mesh of Public Services | Illustrates a networked mesh of public and local services with IPC and process-level integration. |
| 17_pubtraffic | ๐ Multiprocessing | Dynamic Model, Events | Demonstrates dynamic application model creation and event handling in a multi-process IPC system. |
| 18_pubworker | ๐ Multiprocessing | Worker Threads, Custom Events | Shows worker thread usage for handling custom events in multithreaded IPC scenarios. |
| 19_pubfsm | ๐ Multiprocessing | FSM, State-Driven | Implements a finite state machine to control public service behavior with IPC support. |
| 20_winchat | ๐ Multiprocessing | Windows Chat, Real-Time | Demonstrates a Windows-based chat application using IPC with fault-tolerant public services. |
| 21_locwatchdog | ๐งต Multithreading | Watchdog, Fault-Tolerance | Implements a local service watchdog to monitor threads and automatically restart failed services. |
| 22_pubwatchdog | ๐ Multiprocessing | Watchdog, IPC | Extends watchdog functionality to monitor public services across processes, ensuring fault-tolerant operations. |
| 23_pubdatarate | ๐ Multiprocessing | Data Rate, IPC | Measures data transfer rates between public services and clients; useful for performance benchmarking. โ Benchmark results |
| 24_pubunblock | ๐ Multiprocessing | Manual Unblocking, Throughput | Demonstrates manually unblocking service requests to optimize handling in asynchronous communication. |
| 25_pubsub | ๐ Multiprocessing | Pub/Sub, IPC | Implements the Publish/Subscribe pattern with notifications on change or on every update for subscribed clients. |
| 26_pubsubmix | ๐ Multiprocessing | Hybrid Pub/Sub, Fault-Tolerance | Shows mixed Pub/Sub configuration across threads and processes; maintains reliability during network interruptions. |
| 27_pubsubmulti | ๐ Multiprocessing | Multi-Subscriber, Efficient Events | Optimizes Pub/Sub with multiple subscribers per thread, reducing event overhead and improving efficiency. |
| 28_stlsync | ๐งต Multithreading | Synchronization Event and STL | Event-based synchronization with STL threads for safe multithreading. |
| 29_syncevent | ๐งต Multithreading | Auto-Reset Events, Signal Persistence | Demonstrates reliable Areg SyncEvent signaling: events stay signaled until locked, no spurious wakeups, works the same on Windows and Linux. |
| 30_publatency | ๐ Multiprocessing | Latency Benchmark, RTT, OWT | Measures full-stack IPC latency across payload sizes using ping-pong RTT and broadcast one-way tests. โ Benchmark results |
| 31_loclatency | ๐งต Multithreading | Local Latency Benchmark, RTT, OWT | Measures in-process latency for the same payload sizes: provider and consumer in one thread, and in two threads. Needs no router, runs unattended, and is the local counterpart of 30_publatency. |
| 32_pubmixed | ๐ Multiprocessing | Mixed Traffic, Head-of-Line Latency | Runs a bulk stream and small request/response on the same connection and measures what the bulk costs the small messages. Shows how queue::capacity bounds both memory and small-message latency. |
Conclusion
These examples demonstrate Areg SDK's core strengths:
- Scalable multithreaded and multi-process applications
- Fault-tolerant services with automatic recovery
- Real-time, event-driven systems
- Complex Publish/Subscribe and service mesh architectures
Use them as practical references for understanding patterns, best practices, and high-performance solutions provided by Areg SDK.