Welcome to the official qb documentation. Here you will find a detailed view of all the qb classes, functions and modules.
qb provides technology solutions and services dedicated to high performance real-time complex processing, enabling low and predictable latency, perfect scalability and high throughput. It's a complete development framework for multicore processing that has been specifically designed for low latency and low footprint on multicore processors.
qb is a thin-layer multicore-optimized runtime that enable users to build their own business-driven, jitter-free, low-latency, and elastic Reactive software based on the Actor model.
Requirements
C++17 compiler, (gcc7, clang4, msvc19.11)
(Recommended) cmake
(Recommended) Disable the HyperThreading to optimize your Physical Cores Cache
Build Status
linux
Windows
Coverage
master
/>
develop
/>
experimental
/>
Pros
Opensource
Cross-platform (Linux|Windows)
Easy to use
CPU cache friendly
Very fast and low-latency
Reusable code from a project to another
Forget everything about multi-threading concurrency issues
Coins
Strong CPU usage
...
License
Apache Version 2
Introduction
Our CPUs are not getting any faster. What’s happening is that we now have multiple cores on them. If we want to take advantage of all this hardware we have available now, we need a way to run our code concurrently. Decades of untraceable bugs and developers’ depression have shown that threads are not the way to go.
Definition
The Actor model is a concurrent model of computation that treats "actors" as the universal primitives of concurrent computation.
The Actor sends event messages to be received by another Actor, which is then treated by an Event handler.
The Event handler can execute a local function, create more actors, and send events to other Actors. In qb programming semantics, Actors shall be mono-threaded and non-blocking.
The Event communication between Actors is done with an unidirectional communication channel called a Pipe. Hence, the Actor programming model is completely asynchronous and event-driven.
qb + Actor Model
A program developed with qb is consisting of multiple actors handling one or multiple events attached to several cores linked together with several pipes. Once designed, the programming is broken down into coding mono-threaded and sequential event handlers. Hence, the Actor model which is scalable and parallel by nature.
qb runtime will handle all the rest and bridge the gap between parallel programming and hardware multicore complexity.
Getting Started !
Example ping-pong project
First, you'll have to create the project directory and cd into it
$> mkdir pingpong && cd pingpong
Then clone the qb framework by doing:
$> git clone git@github.com:isndev/qb.git
Next, create CMakeLists.txt file and paste the content below
# CMakeLists.txt file
cmake_minimum_required(VERSION 3.10)
project(pingpong)
# qb minimum requirements
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/qb")
# Add qb framework
add_subdirectory(${QB_PATH})
# Define your project source
set(SOURCE main.cpp)
add_executable(pingpong ${SOURCE})
# Link target with qb-core library
target_link_libraries(pingpong qb-core)
Define your first event with its custom data
MyEvent.h :
// MyEvent.h
#include <vector>
#include <qb/event.h>
#ifndef MYEVENT_H_
# define MYEVENT_H_
// Event example
struct MyEvent
: publicqb::Event// /!\ should inherit from qb event
{
int data; // trivial data
std::vector<int> container; // dynamic data
// /!\ an event must never store an address of it own data
// /!\ ex : int *ptr = &data;
// /!\ avoid using std::string, instead use :
// /!\ - fixed cstring
// /!\ - pointer of std::string
// /!\ - or compile with old ABI '-D_GLIBCXX_USE_CXX11_ABI=0'
};
#endif
Let's define the PingActor
PingActor will send MyEvent to PongActor, receive the response and kill himself
PingActor.h :
// PingActor.h file
#include <qb/actor.h>
#include "MyEvent.h"
#ifndef PINGACTOR_H_
# define PINGACTOR_H_
class PingActor
: publicqb::Actor// /!\ should inherit from qb actor