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.

  1. Clone the Repository
git clone https://github.com/aregtech/areg-sdk.git
cd areg-sdk
  1. 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.

  1. 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_generated are created from Service Interface (.siml) documents during build.
  • Windows-only Projects: 20_winchat requires MFC and MSVC/ClangCL compilers.

Example Projects

ProjectScopeHighlightsKey Feature / Solution
01_minimalrpc๐Ÿงต MultithreadingObject RPC, Minimal SetupMinimal thread-to-thread RPC with auto-discovery; provider handles request and signals app quit.
02_minimalipc๐Ÿš€ MultiprocessingIPC, Minimal SetupDemonstrates minimal inter-process communication setup; illustrates message exchange across processes via mtrouter.
03_helloservice๐Ÿš€ MultiprocessingService/Client, Threading ModelIntroduces service creation and client-server interactions; flexible threading and process models for IPC.
04_hellothread๐Ÿงต MultithreadingThread LifecycleDemonstrates thread creation, management, and synchronization; prints "Hello World!" in a separate thread.
05_buffer๐Ÿงต MultithreadingShared Memory, SerializationShows how to serialize data into a shared buffer, pass it between threads, and deserialize it in another thread.
06_file๐Ÿงต MultithreadingFile HandlingDemonstrates reading, writing, copying, and deleting files in text and binary formats across threads.
07_logging๐Ÿงต MultithreadingLogging, TracingShows application method call tracing and message logging for debugging and runtime analysis.
08_timer๐Ÿงต MultithreadingTimers, Real-Time EventsDemonstrates one-shot, periodic, and continuous timers for real-time event handling in threads.
09_threads๐Ÿงต MultithreadingEvent Dispatching, ThreadsIllustrates creating custom event dispatching threads for real-time multithreaded applications.
10_sync๐Ÿงต MultithreadingMutex, EventsDemonstrates synchronization primitives (mutexes, events) for safe multithreaded operations.
11_service๐Ÿงต MultithreadingService ProviderShows single-threaded service provider creation and deployment within an application model.
12_svcmulti๐Ÿงต MultithreadingService ReuseDemonstrates service reuse across multiple threads and processes within an application model.
13_locsvc๐Ÿงต MultithreadingLocal ServiceIntroduces a local service; demonstrates Service Provider and Consumer communication in a single process.
14_locmesh๐Ÿงต MultithreadingService MeshShows a mesh of local services communicating across multiple threads for real-time interactions.
15_pubsvc๐Ÿš€ MultiprocessingPublic Service, IPCDemonstrates a public service provider and client communication across processes using Object RPC.
16_pubmesh๐Ÿš€ MultiprocessingMesh of Public ServicesIllustrates a networked mesh of public and local services with IPC and process-level integration.
17_pubtraffic๐Ÿš€ MultiprocessingDynamic Model, EventsDemonstrates dynamic application model creation and event handling in a multi-process IPC system.
18_pubworker๐Ÿš€ MultiprocessingWorker Threads, Custom EventsShows worker thread usage for handling custom events in multithreaded IPC scenarios.
19_pubfsm๐Ÿš€ MultiprocessingFSM, State-DrivenImplements a finite state machine to control public service behavior with IPC support.
20_winchat๐Ÿš€ MultiprocessingWindows Chat, Real-TimeDemonstrates a Windows-based chat application using IPC with fault-tolerant public services.
21_locwatchdog๐Ÿงต MultithreadingWatchdog, Fault-ToleranceImplements a local service watchdog to monitor threads and automatically restart failed services.
22_pubwatchdog๐Ÿš€ MultiprocessingWatchdog, IPCExtends watchdog functionality to monitor public services across processes, ensuring fault-tolerant operations.
23_pubdatarate๐Ÿš€ MultiprocessingData Rate, IPCMeasures data transfer rates between public services and clients; useful for performance benchmarking. โ†’ Benchmark results
24_pubunblock๐Ÿš€ MultiprocessingManual Unblocking, ThroughputDemonstrates manually unblocking service requests to optimize handling in asynchronous communication.
25_pubsub๐Ÿš€ MultiprocessingPub/Sub, IPCImplements the Publish/Subscribe pattern with notifications on change or on every update for subscribed clients.
26_pubsubmix๐Ÿš€ MultiprocessingHybrid Pub/Sub, Fault-ToleranceShows mixed Pub/Sub configuration across threads and processes; maintains reliability during network interruptions.
27_pubsubmulti๐Ÿš€ MultiprocessingMulti-Subscriber, Efficient EventsOptimizes Pub/Sub with multiple subscribers per thread, reducing event overhead and improving efficiency.
28_stlsync๐Ÿงต MultithreadingSynchronization Event and STLEvent-based synchronization with STL threads for safe multithreading.
29_syncevent๐Ÿงต MultithreadingAuto-Reset Events, Signal PersistenceDemonstrates reliable Areg SyncEvent signaling: events stay signaled until locked, no spurious wakeups, works the same on Windows and Linux.
30_publatency๐Ÿš€ MultiprocessingLatency Benchmark, RTT, OWTMeasures full-stack IPC latency across payload sizes using ping-pong RTT and broadcast one-way tests. โ†’ Benchmark results
31_loclatency๐Ÿงต MultithreadingLocal Latency Benchmark, RTT, OWTMeasures 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๐Ÿš€ MultiprocessingMixed Traffic, Head-of-Line LatencyRuns 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.