SlideShare a Scribd company logo
1 of 73
Download to read offline
CoreHard C++ Autumn 2016
Actor Model and C++:
what, why and how?
Yauheni Akhotnikau
What will be discussed?
Multithreading and parallel concurrent computing.
Actor Model in two-three-four-...-twelve slides.
Today's "Actor Model" icons. All two.
What about C++ (isn't it dead)?
NIH*-syndrome or is there something for C++?
2* NIH - Not Invented Here
Multithreading is...
a tool which is actively used in two very different areas:
● parallel computing (the same actions are performed simultaneously on
several datasets of the same type);
● concurrent computing (different actions are performed on different datasets
of different types).
Concurrent computing can be without usage of multithreading. But with
multithreading the concurrent computing is the most difficult...
3
We will speak about multithreading...
...only in the context of concurrent computing.
Actor Model shines here.
Quite different approaches and tools are used for parallel computing...
4
Multithreading is difficult
Yes, it is difficult.
Even with 20 years' experience.
But why?
5
Mutable shared state
Mutable shared state is one of the main factors of multithreading's difficulty.
6
How to make life easier?
7
Remove shared state
Nothing to share. Nothing to fight for.
Let every thread has its own private state. No one has access to that state, except
owner thread.
This is a shared nothing* principle.
8* https://en.wikipedia.org/wiki/Shared_nothing_architecture
Remove shared state
What if thread X requires some data which belongs to thread Y?
What if thread Y wants to do some changes in thread Z's data?
9
Threads need interaction. But how?
It seems that there are two ways:
1. Synchronous.
2. Asynchronous.
But it is wrong...
10
In real life...
...there is no place for synchronous interaction, only hardcore asynchronous.
An example based on message-passing:
● thread X sends a request message to thread Y;
● thread Y receives the request from thread X, processes it and sends reply
message to thread X;
● thread Y sends an update message to thread Z;
● thread Z receives the update from thread Y and updates its own data.
11
It is dead simple!
There are some threads. Every thread has its incoming message queue.
A thread sleeps while incoming queue is empty.
Thread wakes up when some incoming messages arrived.
If thread X wants something from thread Y then X sends a message into Y's
incoming queue.
If thread Y wants to answer X then Y sends a message into X's incoming queue.
12
If a message carries copy of data...
...then we have a bonus: a transparent transition to distributed application.
If thread Y passes a copy of the data into message Msg then there is almost no
difference whether Msg is going into local incoming queue of thread Z or into a
queue for transmitting message on different host.
The Msg is self-sufficient. That's why it can be serialized, transmitted via network,
deserialized and handled.
13
That's the trick! :)
Actor Model is just about it.
It is just about isolated control flows.
It is just about communications based on message-passing.
14
Actor Model
Was born in 1973 as a result of Carl Hewitt's works.
Was extended in 1981 by William Clinger.
And in 1985 by Gul Agha.
But this dates are related to formalized Actor Model.
Informally this model was discovered and rediscovered multiple times.
15
Actor Model
There are some starting points for those who want to dive deep into formal theory
of Actor Model:
https://en.wikipedia.org/wiki/History_of_the_Actor_model
https://en.wikipedia.org/wiki/Actor_model
https://en.wikipedia.org/wiki/Actor_model_theory
16
Actor Model. Basic principles
● actor is an entity with behaviour;
● actors react to incoming messages;
● when an incoming message arrives an actor can:
○ send some (limited) number of messages to other actors;
○ create some (limited) number of new actors;
○ define a new behaviour for itself for processing of new messages.
17
Actor is some entity
No more than that.
A separate process can be seen as an actor. Erlang is an example.
A separate OS thread ("green" thread, fiber, ...) can be seen as an actor. For
example goroutines in Go can be treated as actors.
An object for which a working context is provided by someone can be seen as an
actor. Akka as an example.
18
And yet another time: actor is some entity
Actor Model doesn't require that an actor is a process, or a thread, or a finite
automata, or something else.
That's why present and well known implementations of Actor Model have so many
differences.
19
Actor Model is 40+ years old
There were several waves of popularity and oblivion.*
Now we see next wave of popularity. This wave began somewhere 10-12 years
ago. Main drivers were Erlang and then Akka.
20* Why has the actor model not succeeded?
Today's icons: Erlang
Erlang is probably the most famous implementation*.
http://www.erlang.org/
But not only the language itself but also all other stuff like Erlang VM and OTP.
21* AFAIK, Joe Armstrong never tell that Erlang was influenced by Actor Model
Today's icons: Erlang
Erlang was born in Ericsson's research lab in 1986 as result of Joe Armstrong's
works.
In 1995 a failed project AXE-N (on C++) was closed. Erlang was selected as the
main language for new AXD project.
The result was successful AXD301 with more than million lines of Erlang code.
22
Today's icons: Erlang
Usage of Erlang in Ericsson Radio AB was prohibited in late 1990's.
Joe Armstrong left Ericsson.
Erlang became OpenSource.
Erlang proved itself outside of Ericsson. Ericsson changed its mind.
Joe Armstrong returned to Ericsson in 2004.
23
Today's icons: Erlang
Erlang has been successfully used in many serious projects in last years.
For example: WhatsApp uses Erlang.
Many companies use Erlang in their projects because of its advantages.
24
Today's icons: Erlang (ping-pong example)
-module(tut15).
-export([start/0, ping/2, pong/0]).
ping(0, Pong_PID) ->
Pong_PID ! finished,
io:format("ping finished~n", []);
ping(N, Pong_PID) ->
Pong_PID ! {ping, self()},
receive
pong ->
io:format("Ping received pong~n", [])
end,
ping(N - 1, Pong_PID).
25
pong() ->
receive
finished ->
io:format("Pong finished~n", []);
{ping, Ping_PID} ->
io:format("Pong received ping~n", []),
Ping_PID ! pong,
pong()
end.
start() ->
Pong_PID = spawn(tut15, pong, []),
spawn(tut15, ping, [3, Pong_PID]).
Today's icons: Akka
A framework for Java and Scala.
http://akka.io/
The history began in 2006: Philipp Haller made implementation of Actor Model for
Scala standard library.
In 2008 Jonas Bonér started development of Erlang OTP clone for Scala on top of
actors from Scala-stdlib*. The first public version of Akka was introduced in 2010.
26* http://www.lightbend.com/akka-five-year-anniversary
Today's icons: Akka
Akka is very popular in JVM-world.
Is widely used in areas where JVM's positions are traditionally strong: Web, online
services and enterprise...
Bright examples: LinkedIn and Twitter.
People behind Akka also took their hands on some modern buzz-words like
Reactive Manifesto* and Microservices** :)
27
* http://www.reactivemanifesto.org/
** https://en.wikipedia.org/wiki/Microservices
Today's icons: Akka (ping-pong example)
import akka.actor._
case object PingMessage
case object PongMessage
case object StartMessage
case object StopMessage
class Ping(pong: ActorRef) extends Actor {
var count = 0
def incrementAndPrint { count += 1; println("ping") }
def receive = {
case StartMessage =>
incrementAndPrint
pong ! PingMessage
case PongMessage =>
incrementAndPrint
if (count > 99) {
sender ! StopMessage
println("ping stopped")
context.stop(self)
} else {
sender ! PingMessage
}
28
}
}
class Pong extends Actor {
def receive = {
case PingMessage =>
println(" pong")
sender ! PongMessage
case StopMessage =>
println("pong stopped")
context.stop(self)
}
}
object PingPongTest extends App {
val system = ActorSystem("PingPongSystem")
val pong = system.actorOf(Props[Pong], name = "pong")
val ping = system.actorOf(Props(new Ping(pong)), name = "ping")
// start them going
ping ! StartMessage
}
http://alvinalexander.com/scala/scala-akka-actors-ping-pong-simple-example
But why?
What do Erlang and Akka provide to their users?
Why are they demanded and used in very serious projects?
29
Main reasons:
1. Simplicity. Absence of shared mutable data and interaction via async
messages save developers from pitfalls of traditional multithreading
programming on top of threads and mutexes.
2. Scalability. There can be millions of actors. Even small tasks can be
delegated to separate actors. Actors can be distributed to different processes
and even nodes: async messages make differences almost invisible.
3. Robustness. Some actors can fall. Other actors can detect and repair this
(take look at Erlang's supervisors*). Shared nothing + message-passing
works great there.
30* http://erlang.org/doc/man/supervisor.html
A good quote from Joe Armstrong
I also suspect that the advent of true parallel CPU cores will make
programming parallel systems using conventional mutexes and
shared data structures almost impossibly difficult, and that the pure
message-passing systems will become the dominant way to program
parallel systems.
31A History of Erlang, Joe Armstrong, 2007.
Erlang and Java/Scala (Akka) are safe languages for managed environments
(Erlang VM and JVM).
This influences robustness directly.
An attempt to do a division by zero in some Erlang process is very different from
such attempt in a C++ program.
BTW, some words about robustness
32
What about C++?
Is there any sense to use Actor Model in C++?
33
This is a wrong question!
The right question is:
Do we really need C++?
34
Are we serious? Is this question for CoreHard C++?
Yes :(
35
Do we really need C++?
C++ is a very old language (more than 30 years from public release).
Became a real monster with the standard over 1500 pages long. Not speaking
about forthcoming C++17...
Absorbed many new features (in other words: became even more complex).
Has kept compatibility with more ancient C language. It is still possible to shoot
oneself in the foot.
Every big project uses only subset of C++.
Enormous amount of mammoth's coprolites legacy code.
36
But...
...is there another mainstream native GC-less language which:
● is fast and efficient?
● allows to work on very low level?
● allows to work on very high level of abstractions (OOP, generic programming,
metaprogramming)?
● has such amount of different high quality tools?
● is widely and deeply described in various books, manuals, articles, guidelines
and so on?
● has big, established, live and active community?
There are quite few alternatives. If any.
37
The conclusion is simple: C++ is really needed!
Because of that there is the necessity in tools which make life of C++ developers
easier.
Including implementations of Actor Model for C++.
38
Let a hundred flowers bloom!
More or less actual list of C++ frameworks can be found here:
https://en.wikipedia.org/wiki/Actor_model#Actor_libraries_and_frameworks
It is not the complete list. Some of them are dead now. But anyway...
39
Four tools for a quick look
Now we will take a quick look on four C++ frameworks which:
● are written on C++ and designed for C++;
● show signs of life;
● are cross-platform;
● have some interesting features.
There are also OOSMOS* and Asyncronous Agents Library** (from MS), but they
are not included in the review due to the lack of some conditions mentioned
above.
40
* http://www.oosmos.com/
** https://msdn.microsoft.com/en-us/library/dd492627.aspx
QP/C++
http://www.state-machine.com/qpcpp/
C++98/03. Intended for development of embedded software. Even on bare metal.
Dual licensing.
More than 15 years of evolution and usage.
A high level of conformance with MISRA C++2008 is declared.
41
QP/C++
Actor in QP/C++ is a finite automata. Actor is called active object.
Active object's code can be written by hand.
It is also possible to design an active object in a special visual tool and C++ code
will be generated automatically.
A working context for an active object is provided by QP. Active objects can work
either on different threads or on the same thread depending on the environment.
42
QP/C++ (code example: blinky.h)
#ifndef blinky_h
#define blinky_h
using namespace QP;
enum BlinkySignals {
DUMMY_SIG = Q_USER_SIG,
MAX_PUB_SIG, // the last published signal
TIMEOUT_SIG,
MAX_SIG // the last signal
};
extern QMActive * const AO_Blinky; // opaque pointer
#endif // blinky_h
43
QP/C++ (code example: main.cpp)
#include "qpcpp.h"
#include "bsp.h"
#include "blinky.h"
int main() {
static QEvt const *blinkyQSto[10]; // Event queue storage for Blinky
BSP_init(); // initialize the Board Support Package
QF::init(); // initialize the framework and the underlying RT kernel
// instantiate and start the active objects...
AO_Blinky->start(1U, // priority
blinkyQSto, Q_DIM(blinkyQSto), // event queue
(void *)0, 0U); // stack (unused)
return QF::run(); // run the QF application
}
44
QP/C++ (code example: blinky.cpp, 1)
#include "qpcpp.h"
#include "bsp.h"
#include "blinky.h"
class Blinky : public QActive {
private:
QTimeEvt m_timeEvt;
public:
Blinky();
protected:
static QState initial(Blinky * const me, QEvt const * const e);
static QState off(Blinky * const me, QEvt const * const e);
static QState on(Blinky * const me, QEvt const * const e);
};
Blinky l_blinky;
QMActive * const AO_Blinky = &l_blinky; // opaque pointer
45
QP/C++ (code example: blinky.cpp, 2)
Blinky::Blinky()
: QActive(Q_STATE_CAST(&Blinky::initial)),
m_timeEvt(this, TIMEOUT_SIG, 0U)
{}
QState Blinky::initial(Blinky * const me, QEvt const * const e) {
(void)e; // unused parameter
// arm the time event to expire in half a second and every half second
me->m_timeEvt.armX(BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
return Q_TRAN(&Blinky::off);
}
46
QP/C++ (code example: blinky.cpp, 3)
QState Blinky::off(Blinky * const me, QEvt const * const e)
{
QState status;
switch (e->sig) {
case Q_ENTRY_SIG: {
BSP_ledOff();
status = Q_HANDLED();
break;
}
case TIMEOUT_SIG: {
status = Q_TRAN(&Blinky::on);
break;
}
default: {
status = Q_SUPER(&QHsm::top);
break;
}
}
return status;
}
47
QState Blinky::on(Blinky * const me, QEvt const * const e)
{
QState status;
switch (e->sig) {
case Q_ENTRY_SIG: {
BSP_ledOn();
status = Q_HANDLED();
break;
}
case TIMEOUT_SIG: {
status = Q_TRAN(&Blinky::off);
break;
}
default: {
status = Q_SUPER(&QHsm::top);
break;
}
}
return status;
}
Just::Thread Pro: Actors Edition
http://www.stdthread.co.uk/pro/
C++11.
Commercial license.
Anthony Williams is the author. He wrote a famous book "C++ Concurrency in
Action".
This is almost all good news about this framework :)
A separate OS thread is spawned for every actor :(
48
Just::Thread Pro: Actors Edition (ping-pong)
#include <jss/actor.hpp>
#include <iostream>
#include <thread>
int main()
{
struct pingpong {
jss::actor_ref sender;
pingpong(jss::actor_ref sender_): sender(sender_) {}
};
jss::actor pp1(
[]{
for(;;)
{
jss::actor::receive().match<pingpong>(
[](pingpong p){
std::cout<<"pingn";
p.sender.send(pingpong(jss::actor::self()));
});
}
});
49
jss::actor pp2(
[]{
for(;;)
{
jss::actor::receive().match<pingpong>(
[](pingpong p){
std::cout<<"pongn";
p.sender.send(pingpong(jss::actor::self()));
});
}
});
pp1.send(pingpong(pp2));
std::this_thread::sleep_for(std::chrono::seconds(2));
pp1.stop();
pp2.stop();
}
C++ Actor Framework (aka CAF)
http://www.actor-framework.org/
C++11 or higher (the higher the better).
OpenSource, BSD-3-CLAUSE or Boost licenses.
Most PR-ed implementation of Actor Model for C++.
Is positioned as very fast framework. But it can be discussed* ;)
Is not stabilized yet.
50* Performance Comparison SO-5.5.15.2 vs CAF-0.14.4
C++ Actor Framework (aka CAF)
First versions of CAF copied Erlang as much as possible. But this is changed with
time.
The price for similarity to Erlang is high demands to standard conformance for
C++ compilers. Support for Windows/VC++ was added only after Visual Studio
2015 update 3 release.
Supports traditional async message-passing, request-reply and some kind of
Pub/Sub.
There is also support for distributed application (custom communication protocol
on top of TCP/IP implemented via Boost::Asio).
51
C++ Actor Framework (fixed_stack, 1)
#include <cassert>
#include <cstdint>
#include <iostream>
#include "caf/all.hpp"
using std::endl;
using namespace caf;
namespace {
using pop_atom = atom_constant<atom("pop")>;
using push_atom = atom_constant<atom("push")>;
enum class fixed_stack_errc : uint8_t { push_to_full = 1, pop_from_empty };
error make_error(fixed_stack_errc x) {
return error{static_cast<uint8_t>(x), atom("FixedStack")};
}
52
C++ Actor Framework (fixed_stack, 2)
class fixed_stack : public event_based_actor {
public:
fixed_stack(actor_config& cfg, size_t stack_size)
: event_based_actor(cfg),
size_(stack_size) {
full_.assign(
[=](push_atom, int) -> error {
return fixed_stack_errc::push_to_full;
},
[=](pop_atom) -> int {
auto result = data_.back();
data_.pop_back();
become(filled_);
return result;
}
);
53
C++ Actor Framework (fixed_stack, 3)
filled_.assign(
[=](push_atom, int what) {
data_.push_back(what);
if (data_.size() == size_)
become(full_);
},
[=](pop_atom) -> int {
auto result = data_.back();
data_.pop_back();
if (data_.empty())
become(empty_);
return result;
}
);
54
C++ Actor Framework (fixed_stack, 4)
empty_.assign(
[=](push_atom, int what) {
data_.push_back(what);
become(filled_);
},
[=](pop_atom) -> error {
return fixed_stack_errc::pop_from_empty;
}
);
}
55
C++ Actor Framework (fixed_stack, 5)
behavior make_behavior() override {
assert(size_ < 2);
return empty_;
}
private:
size_t size_;
std::vector<int> data_;
behavior full_;
behavior filled_;
behavior empty_;
};
56
C++ Actor Framework (fixed_stack, 6)
void caf_main(actor_system& system) {
scoped_actor self{system};
auto st = self->spawn<fixed_stack>(5u);
// fill stack
for (int i = 0; i < 10; ++i) self->send(st, push_atom::value, i);
// drain stack
aout(self) << "stack: { ";
bool stack_empty = false;
while (!stack_empty) {
self->request(st, std::chrono::seconds(10), pop_atom::value).receive(
[&](int x) {
aout(self) << x << " ";
},
[&](const error&) {
stack_empty = true;
}
);
}
aout(self) << "}" << endl;
self->send_exit(st, exit_reason::user_shutdown);
}
} // namespace <anonymous>
CAF_MAIN()
57
SObjectizer-5
https://sourceforge.net/projects/sobjectizer/ or https://github.com/eao197/so-5-5
C++11 (minimal: GCC 4.8, MSVC++12.0).
OpenSource, BSD-3-CLAUSE license.
Has very long story behind:
1995-2000: Homyel, Development Bureau of System Programming, SCADA Objectizer;
2002-...: Homyel-Moscow, Intervale, SObjectizer-4;
2010-...: Homyel-Moscow, Intervale and The SObjectizer Team, SObjectizer-5.
58
SObjectizer-5
SO-4 in production since 2002. Still working.
SO-5 in production since 2011.
Backward compatibility – must have.
We can't introduce breaking changes in every release. Simply can't.
Version SO-5.5.0 was released in Oct 2014. There is no breaking changes in 5.5.* branch
since then. The last stable version 5.5.18 is released in Sep 2016.
59
SObjectizer-5
Actors in SO-5 are called agents.
Agents in SO-5 are hierarchical finite automatas (nested states, enter/exit
handlers, shallow- and deep-history, time limits).
Working contexts for agents are provided by dispatchers.
There are eight types of dispatchers available just "out of box".
Distributed applications are not supported in SO-5. There was an experience in
SO-4. Because of that we decided to use commodity tools which are appropriate
for a specific task (MQTT, AMQP, HTTP and so on).
60
SObjectizer-5
SO-5 is a symbiose of Actor Model, Publish/Subscribe and CSP*
Messages are sent to a message box (mbox), not to a particular agent. There
could be one agent behind a mbox. Or multiple agents. Or no one.
Mbox is like a Topic in Pub/Sub. Message sending is like a Publish in Pub/Sub.
Like in Pub/Sub an agent must be subscribed to the message to receive it.
61* https://en.wikipedia.org/wiki/Communicating_sequential_processes
SObjectizer-5 (blinking_led, 1)
#include <iostream>
#include <so_5/all.hpp>
class blinking_led final : public so_5::agent_t
{
state_t off{ this }, blinking{ this },
blink_on{ initial_substate_of{ blinking } },
blink_off{ substate_of{ blinking } };
public :
struct turn_on_off : public so_5::signal_t {};
62
SObjectizer-5 (blinking_led, 2)
blinking_led( context_t ctx ) : so_5::agent_t{ ctx }
{
this >>= off;
off.just_switch_to< turn_on_off >( blinking );
blinking.just_switch_to< turn_on_off >( off );
blink_on
.on_enter( []{ std::cout << "ON" << std::endl; } )
.on_exit( []{ std::cout << "off" << std::endl; } )
.time_limit( std::chrono::milliseconds{1250}, blink_off );
blink_off
.time_limit( std::chrono::milliseconds{750}, blink_on );
}
};
63
SObjectizer-5 (blinking_led, 3)
int main() {
so_5::launch( []( so_5::environment_t & env ) {
so_5::mbox_t m;
env.introduce_coop( [&]( so_5::coop_t & coop ) {
auto led = coop.make_agent< blinking_led >();
m = led->so_direct_mbox();
} );
auto pause = []( unsigned int v ) { std::this_thread::sleep_for( std::chrono::seconds{v} ); };
so_5::send< blinking_led::turn_on_off >( m );
pause( 10 );
so_5::send< blinking_led::turn_on_off >( m );
pause( 5 );
so_5::send< blinking_led::turn_on_off >( m );
pause( 5 );
env.stop();
} );
}
64
Conclusion 1/3
Actor Model is a great approach for cases where it can be used1
.
It is proved many times in various projects where Erlang and Akka were
successfully used.
Someone said that async message-passing is the future. Just listen to Joe
Armstrong, he knows what he says;)
1)
Don't believe in an advertisement: it can be used not in every case.
65
Conclusion 2/3
Our experience shows that there is sense in usage of Actor Model in C++. If you
have an appropriate tool.
There are already built and ready to use tools for C++.
Very different tools. For different users.
With different prices, of course.
It is necessary to pay for usage of QP/C++ or Just::Thread Pro in a proprietary projects.
SObjectizer and CAF can be used for free.
66
Conclusion 3/3
It is a very bad idea to start the development of your own actor framework for C++.
We have tried. It's a thankless job. Just believe us :)
It is better to get something already existing. Hint: the name begins from SObj... ;)
Just provide a chance to shoot oneself in a foot to developers of an actor
framework. They enjoy it :)
67
Thanks for patience!
Questions?
68
Bonus track (SO-5's fixed_stack, 1)
#include <iostream>
#include <so_5/all.hpp>
class fixed_stack final : public so_5::agent_t
{
state_t st_empty{ this },
st_filled{ this },
st_full{ this };
const size_t m_max_size;
std::vector< int > m_stack;
public :
class empty_stack final : public std::logic_error
{
public :
using std::logic_error::logic_error;
};
struct push { int m_val; };
struct pop : public so_5::signal_t {};
69* https://bitbucket.org/sobjectizerteam/fixed_stack_example
Bonus track (SO-5's fixed_stack, 2)
fixed_stack( context_t ctx, size_t max_size )
: so_5::agent_t( ctx )
, m_max_size( max_size )
{
this >>= st_empty;
so_subscribe_self()
.in( st_empty )
.in( st_filled )
.event( &fixed_stack::on_push );
so_subscribe_self()
.in( st_filled )
.in( st_full )
.event( &fixed_stack::on_pop_when_not_empty );
so_subscribe_self()
.in( st_empty )
.event( &fixed_stack::on_pop_when_empty );
}
70
Bonus track (SO-5's fixed_stack, 3)
private :
void on_push( const push & w )
{
m_stack.push_back( w.m_val );
this >>= ( m_stack.size() == m_max_size ? st_full : st_filled );
}
int on_pop_when_not_empty( mhood_t< pop > )
{
auto r = m_stack.back();
m_stack.pop_back();
this >>= ( m_stack.empty() ? st_empty : st_filled );
return r;
}
int on_pop_when_empty( mhood_t< pop > )
{
throw empty_stack( "empty_stack" );
}
};
71
Bonus track (SO-5's fixed_stack, 4)
int main() {
try {
so_5::launch( []( so_5::environment_t & env ) {
so_5::mbox_t stack;
env.introduce_coop( [&stack]( so_5::coop_t & coop ) {
stack = coop.make_agent< fixed_stack >( 5u )->so_direct_mbox();
} );
for( int i = 0; i < 10; ++i ) so_5::send< fixed_stack::push >( stack, i );
std::cout << "stack { ";
try {
for(;;)
std::cout << so_5::request_value< int, fixed_stack::pop >( stack, std::chrono::seconds(10) ) << " ";
}
catch( const fixed_stack::empty_stack & ) {}
std::cout << "}" << std::endl;
env.stop();
} );
return 0;
}
catch( const std::exception & x ) {
std::cerr << "Oops! " << x.what() << std::endl;
}
return 2;
}
72
SObjectizer Wiki: https://sourceforge.net/p/sobjectizer/wiki/Home/
Serie of slides "Dive into SObjectizer-5.5":
Intro, Agent's States, More About Coops, Exceptions, Timers, Synchonous Interaction, Message
Limits, Dispatchers, Message Chains.
Author's blog: eao197.blogspot.com (in Russian)
About SObjectizer in author's blog: eao197.blogspot.com/search/label/SObjectizer
Author's email: eao197 at stiffstream com
If you need a commercial support for SO-5: stiffstream.com
73

More Related Content

What's hot

Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBScyllaDB
 
Building an Authorization Solution for Microservices Using Neo4j and OPA
Building an Authorization Solution for Microservices Using Neo4j and OPABuilding an Authorization Solution for Microservices Using Neo4j and OPA
Building an Authorization Solution for Microservices Using Neo4j and OPANeo4j
 
Building Data Pipelines with Spark and StreamSets
Building Data Pipelines with Spark and StreamSetsBuilding Data Pipelines with Spark and StreamSets
Building Data Pipelines with Spark and StreamSetsPat Patterson
 
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...Henning Jacobs
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability SolutionsMydbops
 
Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...
Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...
Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...HostedbyConfluent
 
Performance Analysis and Optimizations for Kafka Streams Applications
Performance Analysis and Optimizations for Kafka Streams ApplicationsPerformance Analysis and Optimizations for Kafka Streams Applications
Performance Analysis and Optimizations for Kafka Streams ApplicationsGuozhang Wang
 
Handle Large Messages In Apache Kafka
Handle Large Messages In Apache KafkaHandle Large Messages In Apache Kafka
Handle Large Messages In Apache KafkaJiangjie Qin
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019VMware Tanzu
 
Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...
Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...
Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...Databricks
 
Apache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorApache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorMarc Lamberti
 
CQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsCQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsMichael Blackstock
 
SQream DB, GPU-accelerated data warehouse
SQream DB, GPU-accelerated data warehouseSQream DB, GPU-accelerated data warehouse
SQream DB, GPU-accelerated data warehouseNAVER Engineering
 
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화NAVER D2
 
Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...
Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...
Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...Spark Summit
 
Redpanda and ClickHouse
Redpanda and ClickHouseRedpanda and ClickHouse
Redpanda and ClickHouseAltinity Ltd
 
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMillDelivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMillHostedbyConfluent
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.Taras Matyashovsky
 

What's hot (20)

Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
 
Building an Authorization Solution for Microservices Using Neo4j and OPA
Building an Authorization Solution for Microservices Using Neo4j and OPABuilding an Authorization Solution for Microservices Using Neo4j and OPA
Building an Authorization Solution for Microservices Using Neo4j and OPA
 
Building Data Pipelines with Spark and StreamSets
Building Data Pipelines with Spark and StreamSetsBuilding Data Pipelines with Spark and StreamSets
Building Data Pipelines with Spark and StreamSets
 
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
Ensuring Kubernetes Cost Efficiency across (many) Clusters - DevOps Gathering...
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
 
Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...
Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...
Druid + Kafka: transform your data-in-motion to analytics-in-motion | Gian Me...
 
Performance Analysis and Optimizations for Kafka Streams Applications
Performance Analysis and Optimizations for Kafka Streams ApplicationsPerformance Analysis and Optimizations for Kafka Streams Applications
Performance Analysis and Optimizations for Kafka Streams Applications
 
Handle Large Messages In Apache Kafka
Handle Large Messages In Apache KafkaHandle Large Messages In Apache Kafka
Handle Large Messages In Apache Kafka
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
Greenplum and Kafka: Real-time Streaming to Greenplum - Greenplum Summit 2019
 
Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...
Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...
Building Data Product Based on Apache Spark at Airbnb with Jingwei Lu and Liy...
 
Apache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorApache Airflow | What Is An Operator
Apache Airflow | What Is An Operator
 
CQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsCQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applications
 
SQream DB, GPU-accelerated data warehouse
SQream DB, GPU-accelerated data warehouseSQream DB, GPU-accelerated data warehouse
SQream DB, GPU-accelerated data warehouse
 
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
[231]운영체제 수준에서의 데이터베이스 성능 분석과 최적화
 
Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...
Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...
Going Real-Time: Creating Frequently-Updating Datasets for Personalization: S...
 
Redpanda and ClickHouse
Redpanda and ClickHouseRedpanda and ClickHouse
Redpanda and ClickHouse
 
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMillDelivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
Delivering: from Kafka to WebSockets | Adam Warski, SoftwareMill
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 

Viewers also liked

Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++Yauheni Akhotnikau
 
C++ Core Guidelines
C++ Core Guidelines C++ Core Guidelines
C++ Core Guidelines Sergey Zubkov
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itSergey Platonov
 
Dive into SObjectizer 5.5. Introductory part
Dive into SObjectizer 5.5. Introductory partDive into SObjectizer 5.5. Introductory part
Dive into SObjectizer 5.5. Introductory partYauheni Akhotnikau
 
Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?Yauheni Akhotnikau
 
Использование юнит-тестов для повышения качества разработки
Использование юнит-тестов для повышения качества разработкиИспользование юнит-тестов для повышения качества разработки
Использование юнит-тестов для повышения качества разработкиvictor-yastrebov
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3Platonov Sergey
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit TestingDmitry Vyukov
 
Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017
Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017
Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017Mikhail Matrosov
 
Григорий Демченко, Универсальный адаптер
Григорий Демченко, Универсальный адаптерГригорий Демченко, Универсальный адаптер
Григорий Демченко, Универсальный адаптерSergey Platonov
 
Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?Yauheni Akhotnikau
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect AndromedaElectronic Arts / DICE
 
Dive into SObjectizer-5.5. Sixth part: Synchronous Interaction
Dive into SObjectizer-5.5. Sixth part: Synchronous InteractionDive into SObjectizer-5.5. Sixth part: Synchronous Interaction
Dive into SObjectizer-5.5. Sixth part: Synchronous InteractionYauheni Akhotnikau
 
Dive into SObjectizer 5.5. Third part. Coops
Dive into SObjectizer 5.5. Third part. CoopsDive into SObjectizer 5.5. Third part. Coops
Dive into SObjectizer 5.5. Third part. CoopsYauheni Akhotnikau
 
модель акторов и C++ что, зачем и как ?
модель акторов и C++ что, зачем и как ?модель акторов и C++ что, зачем и как ?
модель акторов и C++ что, зачем и как ?corehard_by
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...Gianluca Padovani
 
Антон Бикинеев, Reflection in C++Next
Антон Бикинеев,  Reflection in C++NextАнтон Бикинеев,  Reflection in C++Next
Антон Бикинеев, Reflection in C++NextSergey Platonov
 

Viewers also liked (20)

Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++
 
C++ Core Guidelines
C++ Core Guidelines C++ Core Guidelines
C++ Core Guidelines
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Dive into SObjectizer 5.5. Introductory part
Dive into SObjectizer 5.5. Introductory partDive into SObjectizer 5.5. Introductory part
Dive into SObjectizer 5.5. Introductory part
 
What is SObjectizer 5.5
What is SObjectizer 5.5What is SObjectizer 5.5
What is SObjectizer 5.5
 
Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?
 
Clang tidy
Clang tidyClang tidy
Clang tidy
 
Использование юнит-тестов для повышения качества разработки
Использование юнит-тестов для повышения качества разработкиИспользование юнит-тестов для повышения качества разработки
Использование юнит-тестов для повышения качества разработки
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit Testing
 
Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017
Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017
Повседневный С++: алгоритмы и итераторы @ C++ Russia 2017
 
Григорий Демченко, Универсальный адаптер
Григорий Демченко, Универсальный адаптерГригорий Демченко, Универсальный адаптер
Григорий Демченко, Универсальный адаптер
 
Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
 
Dive into SObjectizer-5.5. Sixth part: Synchronous Interaction
Dive into SObjectizer-5.5. Sixth part: Synchronous InteractionDive into SObjectizer-5.5. Sixth part: Synchronous Interaction
Dive into SObjectizer-5.5. Sixth part: Synchronous Interaction
 
Dive into SObjectizer 5.5. Third part. Coops
Dive into SObjectizer 5.5. Third part. CoopsDive into SObjectizer 5.5. Third part. Coops
Dive into SObjectizer 5.5. Third part. Coops
 
модель акторов и C++ что, зачем и как ?
модель акторов и C++ что, зачем и как ?модель акторов и C++ что, зачем и как ?
модель акторов и C++ что, зачем и как ?
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...
 
Антон Бикинеев, Reflection in C++Next
Антон Бикинеев,  Reflection in C++NextАнтон Бикинеев,  Reflection in C++Next
Антон Бикинеев, Reflection in C++Next
 

Similar to Actor Model and C++: what, why and how?

Actor Model and C++: what, why and how? (March 2020 Edition)
Actor Model and C++: what, why and how? (March 2020 Edition)Actor Model and C++: what, why and how? (March 2020 Edition)
Actor Model and C++: what, why and how? (March 2020 Edition)Yauheni Akhotnikau
 
How my visualization tools use little memory: A tale of incrementalization an...
How my visualization tools use little memory: A tale of incrementalization an...How my visualization tools use little memory: A tale of incrementalization an...
How my visualization tools use little memory: A tale of incrementalization an...Eugene Kirpichov
 
Third Gen Production ML Architectures: Lessons from History, Experiences with...
Third Gen Production ML Architectures: Lessons from History, Experiences with...Third Gen Production ML Architectures: Lessons from History, Experiences with...
Third Gen Production ML Architectures: Lessons from History, Experiences with...M Waleed Kadous
 
Computing with Directed Labeled Graphs
Computing with Directed Labeled GraphsComputing with Directed Labeled Graphs
Computing with Directed Labeled GraphsMarko Rodriguez
 
DDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirDDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirGianluca Padovani
 
In 2014 Almost Everyone Has Some Kind Of Computer, Whether...
In 2014 Almost Everyone Has Some Kind Of Computer, Whether...In 2014 Almost Everyone Has Some Kind Of Computer, Whether...
In 2014 Almost Everyone Has Some Kind Of Computer, Whether...Katie Parker
 
Akka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya senguptaAkka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya senguptaapgionline
 
Elixir Phoenix
Elixir PhoenixElixir Phoenix
Elixir PhoenixTanuj Soni
 
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Ovidiu Farauanu
 
Evolving as a professional software developer
Evolving as a professional software developerEvolving as a professional software developer
Evolving as a professional software developerAnton Kirillov
 
Java Programming And Object Oriented Programming
Java Programming And Object Oriented ProgrammingJava Programming And Object Oriented Programming
Java Programming And Object Oriented ProgrammingCourtney Bennett
 
On being a professional software developer
On being a professional software developerOn being a professional software developer
On being a professional software developerAnton Kirillov
 
Video Terminal Evolution and The Future of Browsers
Video Terminal Evolution and The Future of BrowsersVideo Terminal Evolution and The Future of Browsers
Video Terminal Evolution and The Future of BrowsersThomas Walker Lynch
 
Антон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabАнтон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabDiana Dymolazova
 
Summer training report on java se6 technology
Summer training  report on java se6 technologySummer training  report on java se6 technology
Summer training report on java se6 technologyShamsher Ahmed
 
An introduction to erlang
An introduction to erlangAn introduction to erlang
An introduction to erlangMirko Bonadei
 
Cilk - An Efficient Multithreaded Runtime System
Cilk - An Efficient Multithreaded Runtime SystemCilk - An Efficient Multithreaded Runtime System
Cilk - An Efficient Multithreaded Runtime SystemShareek Ahamed
 
Deep learning for Industries
Deep learning for IndustriesDeep learning for Industries
Deep learning for IndustriesRahul Kumar
 

Similar to Actor Model and C++: what, why and how? (20)

Actor Model and C++: what, why and how? (March 2020 Edition)
Actor Model and C++: what, why and how? (March 2020 Edition)Actor Model and C++: what, why and how? (March 2020 Edition)
Actor Model and C++: what, why and how? (March 2020 Edition)
 
F461
F461F461
F461
 
Erlang, an overview
Erlang, an overviewErlang, an overview
Erlang, an overview
 
How my visualization tools use little memory: A tale of incrementalization an...
How my visualization tools use little memory: A tale of incrementalization an...How my visualization tools use little memory: A tale of incrementalization an...
How my visualization tools use little memory: A tale of incrementalization an...
 
Third Gen Production ML Architectures: Lessons from History, Experiences with...
Third Gen Production ML Architectures: Lessons from History, Experiences with...Third Gen Production ML Architectures: Lessons from History, Experiences with...
Third Gen Production ML Architectures: Lessons from History, Experiences with...
 
Computing with Directed Labeled Graphs
Computing with Directed Labeled GraphsComputing with Directed Labeled Graphs
Computing with Directed Labeled Graphs
 
DDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirDDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves Elixir
 
In 2014 Almost Everyone Has Some Kind Of Computer, Whether...
In 2014 Almost Everyone Has Some Kind Of Computer, Whether...In 2014 Almost Everyone Has Some Kind Of Computer, Whether...
In 2014 Almost Everyone Has Some Kind Of Computer, Whether...
 
Akka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya senguptaAkka actorstotherescue nirmalya sengupta
Akka actorstotherescue nirmalya sengupta
 
Elixir Phoenix
Elixir PhoenixElixir Phoenix
Elixir Phoenix
 
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
 
Evolving as a professional software developer
Evolving as a professional software developerEvolving as a professional software developer
Evolving as a professional software developer
 
Java Programming And Object Oriented Programming
Java Programming And Object Oriented ProgrammingJava Programming And Object Oriented Programming
Java Programming And Object Oriented Programming
 
On being a professional software developer
On being a professional software developerOn being a professional software developer
On being a professional software developer
 
Video Terminal Evolution and The Future of Browsers
Video Terminal Evolution and The Future of BrowsersVideo Terminal Evolution and The Future of Browsers
Video Terminal Evolution and The Future of Browsers
 
Антон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLabАнтон Кириллов, ZeptoLab
Антон Кириллов, ZeptoLab
 
Summer training report on java se6 technology
Summer training  report on java se6 technologySummer training  report on java se6 technology
Summer training report on java se6 technology
 
An introduction to erlang
An introduction to erlangAn introduction to erlang
An introduction to erlang
 
Cilk - An Efficient Multithreaded Runtime System
Cilk - An Efficient Multithreaded Runtime SystemCilk - An Efficient Multithreaded Runtime System
Cilk - An Efficient Multithreaded Runtime System
 
Deep learning for Industries
Deep learning for IndustriesDeep learning for Industries
Deep learning for Industries
 

More from Yauheni Akhotnikau

arataga. SObjectizer and RESTinio in action: a real-world example
arataga. SObjectizer and RESTinio in action: a real-world examplearataga. SObjectizer and RESTinio in action: a real-world example
arataga. SObjectizer and RESTinio in action: a real-world exampleYauheni Akhotnikau
 
What is SObjectizer 5.7 (at v.5.7.0)
What is SObjectizer 5.7 (at v.5.7.0)What is SObjectizer 5.7 (at v.5.7.0)
What is SObjectizer 5.7 (at v.5.7.0)Yauheni Akhotnikau
 
What is SObjectizer 5.6 (at v.5.6.0)
What is SObjectizer 5.6 (at v.5.6.0)What is SObjectizer 5.6 (at v.5.6.0)
What is SObjectizer 5.6 (at v.5.6.0)Yauheni Akhotnikau
 
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...Yauheni Akhotnikau
 
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...Yauheni Akhotnikau
 
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...Yauheni Akhotnikau
 
Акторы на C++: стоило ли оно того?
Акторы на C++: стоило ли оно того?Акторы на C++: стоило ли оно того?
Акторы на C++: стоило ли оно того?Yauheni Akhotnikau
 
25 Years of C++ History Flashed in Front of My Eyes
25 Years of C++ History Flashed in Front of My Eyes25 Years of C++ History Flashed in Front of My Eyes
25 Years of C++ History Flashed in Front of My EyesYauheni Akhotnikau
 
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them allGECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them allYauheni Akhotnikau
 
Dive into SObjectizer 5.5. Tenth part: Mutable Messages
Dive into SObjectizer 5.5. Tenth part: Mutable MessagesDive into SObjectizer 5.5. Tenth part: Mutable Messages
Dive into SObjectizer 5.5. Tenth part: Mutable MessagesYauheni Akhotnikau
 
Dive into SObjectizer 5.5. Ninth Part: Message Chains
Dive into SObjectizer 5.5. Ninth Part: Message ChainsDive into SObjectizer 5.5. Ninth Part: Message Chains
Dive into SObjectizer 5.5. Ninth Part: Message ChainsYauheni Akhotnikau
 
Dive into SObjectizer 5.5. Eighth Part: Dispatchers
Dive into SObjectizer 5.5. Eighth Part: DispatchersDive into SObjectizer 5.5. Eighth Part: Dispatchers
Dive into SObjectizer 5.5. Eighth Part: DispatchersYauheni Akhotnikau
 
What's new in SObjectizer 5.5.9
What's new in SObjectizer 5.5.9What's new in SObjectizer 5.5.9
What's new in SObjectizer 5.5.9Yauheni Akhotnikau
 
Dive into SObjectizer 5.5. Seventh part: Message Limits
Dive into SObjectizer 5.5. Seventh part: Message LimitsDive into SObjectizer 5.5. Seventh part: Message Limits
Dive into SObjectizer 5.5. Seventh part: Message LimitsYauheni Akhotnikau
 
Dive into SObjectizer 5.5. Fifth part: Timers
Dive into SObjectizer 5.5. Fifth part: TimersDive into SObjectizer 5.5. Fifth part: Timers
Dive into SObjectizer 5.5. Fifth part: TimersYauheni Akhotnikau
 
What’s new in SObjectizer 5.5.8
What’s new in SObjectizer 5.5.8What’s new in SObjectizer 5.5.8
What’s new in SObjectizer 5.5.8Yauheni Akhotnikau
 
Dive into SObjectizer 5.5. Fourth part. Exception
Dive into SObjectizer 5.5. Fourth part. ExceptionDive into SObjectizer 5.5. Fourth part. Exception
Dive into SObjectizer 5.5. Fourth part. ExceptionYauheni Akhotnikau
 
Погружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная частьПогружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная частьYauheni Akhotnikau
 

More from Yauheni Akhotnikau (19)

arataga. SObjectizer and RESTinio in action: a real-world example
arataga. SObjectizer and RESTinio in action: a real-world examplearataga. SObjectizer and RESTinio in action: a real-world example
arataga. SObjectizer and RESTinio in action: a real-world example
 
What is SObjectizer 5.7 (at v.5.7.0)
What is SObjectizer 5.7 (at v.5.7.0)What is SObjectizer 5.7 (at v.5.7.0)
What is SObjectizer 5.7 (at v.5.7.0)
 
What is SObjectizer 5.6 (at v.5.6.0)
What is SObjectizer 5.6 (at v.5.6.0)What is SObjectizer 5.6 (at v.5.6.0)
What is SObjectizer 5.6 (at v.5.6.0)
 
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
[C++ CoreHard Autumn 2018] Actors vs CSP vs Task...
 
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
Shrimp: A Rather Practical Example Of Application Development With RESTinio a...
 
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
Акторы в C++: взгляд старого практикующего актородела (St. Petersburg C++ Use...
 
Акторы на C++: стоило ли оно того?
Акторы на C++: стоило ли оно того?Акторы на C++: стоило ли оно того?
Акторы на C++: стоило ли оно того?
 
25 Years of C++ History Flashed in Front of My Eyes
25 Years of C++ History Flashed in Front of My Eyes25 Years of C++ History Flashed in Front of My Eyes
25 Years of C++ History Flashed in Front of My Eyes
 
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them allGECon 2017: C++ - a Monster that no one likes but that will outlast them all
GECon 2017: C++ - a Monster that no one likes but that will outlast them all
 
Dive into SObjectizer 5.5. Tenth part: Mutable Messages
Dive into SObjectizer 5.5. Tenth part: Mutable MessagesDive into SObjectizer 5.5. Tenth part: Mutable Messages
Dive into SObjectizer 5.5. Tenth part: Mutable Messages
 
Dive into SObjectizer 5.5. Ninth Part: Message Chains
Dive into SObjectizer 5.5. Ninth Part: Message ChainsDive into SObjectizer 5.5. Ninth Part: Message Chains
Dive into SObjectizer 5.5. Ninth Part: Message Chains
 
Dive into SObjectizer 5.5. Eighth Part: Dispatchers
Dive into SObjectizer 5.5. Eighth Part: DispatchersDive into SObjectizer 5.5. Eighth Part: Dispatchers
Dive into SObjectizer 5.5. Eighth Part: Dispatchers
 
What's new in SObjectizer 5.5.9
What's new in SObjectizer 5.5.9What's new in SObjectizer 5.5.9
What's new in SObjectizer 5.5.9
 
Dive into SObjectizer 5.5. Seventh part: Message Limits
Dive into SObjectizer 5.5. Seventh part: Message LimitsDive into SObjectizer 5.5. Seventh part: Message Limits
Dive into SObjectizer 5.5. Seventh part: Message Limits
 
Dive into SObjectizer 5.5. Fifth part: Timers
Dive into SObjectizer 5.5. Fifth part: TimersDive into SObjectizer 5.5. Fifth part: Timers
Dive into SObjectizer 5.5. Fifth part: Timers
 
What’s new in SObjectizer 5.5.8
What’s new in SObjectizer 5.5.8What’s new in SObjectizer 5.5.8
What’s new in SObjectizer 5.5.8
 
Dive into SObjectizer 5.5. Fourth part. Exception
Dive into SObjectizer 5.5. Fourth part. ExceptionDive into SObjectizer 5.5. Fourth part. Exception
Dive into SObjectizer 5.5. Fourth part. Exception
 
Погружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная частьПогружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная часть
 
Обзор SObjectizer 5.5
Обзор SObjectizer 5.5Обзор SObjectizer 5.5
Обзор SObjectizer 5.5
 

Recently uploaded

Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfTobias Schneck
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesShyamsundar Das
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Jaydeep Chhasatia
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionsNirav Modi
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Understanding Native Mobile App Development
Understanding Native Mobile App DevelopmentUnderstanding Native Mobile App Development
Understanding Native Mobile App DevelopmentMobulous Technologies
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageDista
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.Sharon Liu
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 
New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024ThousandEyes
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Incrobinwilliams8624
 

Recently uploaded (20)

Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
Watermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security ChallengesWatermarking in Source Code: Applications and Security Challenges
Watermarking in Source Code: Applications and Security Challenges
 
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
Optimizing Business Potential: A Guide to Outsourcing Engineering Services in...
 
eAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspectionseAuditor Audits & Inspections - conduct field inspections
eAuditor Audits & Inspections - conduct field inspections
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Understanding Native Mobile App Development
Understanding Native Mobile App DevelopmentUnderstanding Native Mobile App Development
Understanding Native Mobile App Development
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 
New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024New ThousandEyes Product Features and Release Highlights: March 2024
New ThousandEyes Product Features and Release Highlights: March 2024
 
Salesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptxSalesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptx
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Inc
 

Actor Model and C++: what, why and how?

  • 1. CoreHard C++ Autumn 2016 Actor Model and C++: what, why and how? Yauheni Akhotnikau
  • 2. What will be discussed? Multithreading and parallel concurrent computing. Actor Model in two-three-four-...-twelve slides. Today's "Actor Model" icons. All two. What about C++ (isn't it dead)? NIH*-syndrome or is there something for C++? 2* NIH - Not Invented Here
  • 3. Multithreading is... a tool which is actively used in two very different areas: ● parallel computing (the same actions are performed simultaneously on several datasets of the same type); ● concurrent computing (different actions are performed on different datasets of different types). Concurrent computing can be without usage of multithreading. But with multithreading the concurrent computing is the most difficult... 3
  • 4. We will speak about multithreading... ...only in the context of concurrent computing. Actor Model shines here. Quite different approaches and tools are used for parallel computing... 4
  • 5. Multithreading is difficult Yes, it is difficult. Even with 20 years' experience. But why? 5
  • 6. Mutable shared state Mutable shared state is one of the main factors of multithreading's difficulty. 6
  • 7. How to make life easier? 7
  • 8. Remove shared state Nothing to share. Nothing to fight for. Let every thread has its own private state. No one has access to that state, except owner thread. This is a shared nothing* principle. 8* https://en.wikipedia.org/wiki/Shared_nothing_architecture
  • 9. Remove shared state What if thread X requires some data which belongs to thread Y? What if thread Y wants to do some changes in thread Z's data? 9
  • 10. Threads need interaction. But how? It seems that there are two ways: 1. Synchronous. 2. Asynchronous. But it is wrong... 10
  • 11. In real life... ...there is no place for synchronous interaction, only hardcore asynchronous. An example based on message-passing: ● thread X sends a request message to thread Y; ● thread Y receives the request from thread X, processes it and sends reply message to thread X; ● thread Y sends an update message to thread Z; ● thread Z receives the update from thread Y and updates its own data. 11
  • 12. It is dead simple! There are some threads. Every thread has its incoming message queue. A thread sleeps while incoming queue is empty. Thread wakes up when some incoming messages arrived. If thread X wants something from thread Y then X sends a message into Y's incoming queue. If thread Y wants to answer X then Y sends a message into X's incoming queue. 12
  • 13. If a message carries copy of data... ...then we have a bonus: a transparent transition to distributed application. If thread Y passes a copy of the data into message Msg then there is almost no difference whether Msg is going into local incoming queue of thread Z or into a queue for transmitting message on different host. The Msg is self-sufficient. That's why it can be serialized, transmitted via network, deserialized and handled. 13
  • 14. That's the trick! :) Actor Model is just about it. It is just about isolated control flows. It is just about communications based on message-passing. 14
  • 15. Actor Model Was born in 1973 as a result of Carl Hewitt's works. Was extended in 1981 by William Clinger. And in 1985 by Gul Agha. But this dates are related to formalized Actor Model. Informally this model was discovered and rediscovered multiple times. 15
  • 16. Actor Model There are some starting points for those who want to dive deep into formal theory of Actor Model: https://en.wikipedia.org/wiki/History_of_the_Actor_model https://en.wikipedia.org/wiki/Actor_model https://en.wikipedia.org/wiki/Actor_model_theory 16
  • 17. Actor Model. Basic principles ● actor is an entity with behaviour; ● actors react to incoming messages; ● when an incoming message arrives an actor can: ○ send some (limited) number of messages to other actors; ○ create some (limited) number of new actors; ○ define a new behaviour for itself for processing of new messages. 17
  • 18. Actor is some entity No more than that. A separate process can be seen as an actor. Erlang is an example. A separate OS thread ("green" thread, fiber, ...) can be seen as an actor. For example goroutines in Go can be treated as actors. An object for which a working context is provided by someone can be seen as an actor. Akka as an example. 18
  • 19. And yet another time: actor is some entity Actor Model doesn't require that an actor is a process, or a thread, or a finite automata, or something else. That's why present and well known implementations of Actor Model have so many differences. 19
  • 20. Actor Model is 40+ years old There were several waves of popularity and oblivion.* Now we see next wave of popularity. This wave began somewhere 10-12 years ago. Main drivers were Erlang and then Akka. 20* Why has the actor model not succeeded?
  • 21. Today's icons: Erlang Erlang is probably the most famous implementation*. http://www.erlang.org/ But not only the language itself but also all other stuff like Erlang VM and OTP. 21* AFAIK, Joe Armstrong never tell that Erlang was influenced by Actor Model
  • 22. Today's icons: Erlang Erlang was born in Ericsson's research lab in 1986 as result of Joe Armstrong's works. In 1995 a failed project AXE-N (on C++) was closed. Erlang was selected as the main language for new AXD project. The result was successful AXD301 with more than million lines of Erlang code. 22
  • 23. Today's icons: Erlang Usage of Erlang in Ericsson Radio AB was prohibited in late 1990's. Joe Armstrong left Ericsson. Erlang became OpenSource. Erlang proved itself outside of Ericsson. Ericsson changed its mind. Joe Armstrong returned to Ericsson in 2004. 23
  • 24. Today's icons: Erlang Erlang has been successfully used in many serious projects in last years. For example: WhatsApp uses Erlang. Many companies use Erlang in their projects because of its advantages. 24
  • 25. Today's icons: Erlang (ping-pong example) -module(tut15). -export([start/0, ping/2, pong/0]). ping(0, Pong_PID) -> Pong_PID ! finished, io:format("ping finished~n", []); ping(N, Pong_PID) -> Pong_PID ! {ping, self()}, receive pong -> io:format("Ping received pong~n", []) end, ping(N - 1, Pong_PID). 25 pong() -> receive finished -> io:format("Pong finished~n", []); {ping, Ping_PID} -> io:format("Pong received ping~n", []), Ping_PID ! pong, pong() end. start() -> Pong_PID = spawn(tut15, pong, []), spawn(tut15, ping, [3, Pong_PID]).
  • 26. Today's icons: Akka A framework for Java and Scala. http://akka.io/ The history began in 2006: Philipp Haller made implementation of Actor Model for Scala standard library. In 2008 Jonas Bonér started development of Erlang OTP clone for Scala on top of actors from Scala-stdlib*. The first public version of Akka was introduced in 2010. 26* http://www.lightbend.com/akka-five-year-anniversary
  • 27. Today's icons: Akka Akka is very popular in JVM-world. Is widely used in areas where JVM's positions are traditionally strong: Web, online services and enterprise... Bright examples: LinkedIn and Twitter. People behind Akka also took their hands on some modern buzz-words like Reactive Manifesto* and Microservices** :) 27 * http://www.reactivemanifesto.org/ ** https://en.wikipedia.org/wiki/Microservices
  • 28. Today's icons: Akka (ping-pong example) import akka.actor._ case object PingMessage case object PongMessage case object StartMessage case object StopMessage class Ping(pong: ActorRef) extends Actor { var count = 0 def incrementAndPrint { count += 1; println("ping") } def receive = { case StartMessage => incrementAndPrint pong ! PingMessage case PongMessage => incrementAndPrint if (count > 99) { sender ! StopMessage println("ping stopped") context.stop(self) } else { sender ! PingMessage } 28 } } class Pong extends Actor { def receive = { case PingMessage => println(" pong") sender ! PongMessage case StopMessage => println("pong stopped") context.stop(self) } } object PingPongTest extends App { val system = ActorSystem("PingPongSystem") val pong = system.actorOf(Props[Pong], name = "pong") val ping = system.actorOf(Props(new Ping(pong)), name = "ping") // start them going ping ! StartMessage } http://alvinalexander.com/scala/scala-akka-actors-ping-pong-simple-example
  • 29. But why? What do Erlang and Akka provide to their users? Why are they demanded and used in very serious projects? 29
  • 30. Main reasons: 1. Simplicity. Absence of shared mutable data and interaction via async messages save developers from pitfalls of traditional multithreading programming on top of threads and mutexes. 2. Scalability. There can be millions of actors. Even small tasks can be delegated to separate actors. Actors can be distributed to different processes and even nodes: async messages make differences almost invisible. 3. Robustness. Some actors can fall. Other actors can detect and repair this (take look at Erlang's supervisors*). Shared nothing + message-passing works great there. 30* http://erlang.org/doc/man/supervisor.html
  • 31. A good quote from Joe Armstrong I also suspect that the advent of true parallel CPU cores will make programming parallel systems using conventional mutexes and shared data structures almost impossibly difficult, and that the pure message-passing systems will become the dominant way to program parallel systems. 31A History of Erlang, Joe Armstrong, 2007.
  • 32. Erlang and Java/Scala (Akka) are safe languages for managed environments (Erlang VM and JVM). This influences robustness directly. An attempt to do a division by zero in some Erlang process is very different from such attempt in a C++ program. BTW, some words about robustness 32
  • 33. What about C++? Is there any sense to use Actor Model in C++? 33
  • 34. This is a wrong question! The right question is: Do we really need C++? 34
  • 35. Are we serious? Is this question for CoreHard C++? Yes :( 35
  • 36. Do we really need C++? C++ is a very old language (more than 30 years from public release). Became a real monster with the standard over 1500 pages long. Not speaking about forthcoming C++17... Absorbed many new features (in other words: became even more complex). Has kept compatibility with more ancient C language. It is still possible to shoot oneself in the foot. Every big project uses only subset of C++. Enormous amount of mammoth's coprolites legacy code. 36
  • 37. But... ...is there another mainstream native GC-less language which: ● is fast and efficient? ● allows to work on very low level? ● allows to work on very high level of abstractions (OOP, generic programming, metaprogramming)? ● has such amount of different high quality tools? ● is widely and deeply described in various books, manuals, articles, guidelines and so on? ● has big, established, live and active community? There are quite few alternatives. If any. 37
  • 38. The conclusion is simple: C++ is really needed! Because of that there is the necessity in tools which make life of C++ developers easier. Including implementations of Actor Model for C++. 38
  • 39. Let a hundred flowers bloom! More or less actual list of C++ frameworks can be found here: https://en.wikipedia.org/wiki/Actor_model#Actor_libraries_and_frameworks It is not the complete list. Some of them are dead now. But anyway... 39
  • 40. Four tools for a quick look Now we will take a quick look on four C++ frameworks which: ● are written on C++ and designed for C++; ● show signs of life; ● are cross-platform; ● have some interesting features. There are also OOSMOS* and Asyncronous Agents Library** (from MS), but they are not included in the review due to the lack of some conditions mentioned above. 40 * http://www.oosmos.com/ ** https://msdn.microsoft.com/en-us/library/dd492627.aspx
  • 41. QP/C++ http://www.state-machine.com/qpcpp/ C++98/03. Intended for development of embedded software. Even on bare metal. Dual licensing. More than 15 years of evolution and usage. A high level of conformance with MISRA C++2008 is declared. 41
  • 42. QP/C++ Actor in QP/C++ is a finite automata. Actor is called active object. Active object's code can be written by hand. It is also possible to design an active object in a special visual tool and C++ code will be generated automatically. A working context for an active object is provided by QP. Active objects can work either on different threads or on the same thread depending on the environment. 42
  • 43. QP/C++ (code example: blinky.h) #ifndef blinky_h #define blinky_h using namespace QP; enum BlinkySignals { DUMMY_SIG = Q_USER_SIG, MAX_PUB_SIG, // the last published signal TIMEOUT_SIG, MAX_SIG // the last signal }; extern QMActive * const AO_Blinky; // opaque pointer #endif // blinky_h 43
  • 44. QP/C++ (code example: main.cpp) #include "qpcpp.h" #include "bsp.h" #include "blinky.h" int main() { static QEvt const *blinkyQSto[10]; // Event queue storage for Blinky BSP_init(); // initialize the Board Support Package QF::init(); // initialize the framework and the underlying RT kernel // instantiate and start the active objects... AO_Blinky->start(1U, // priority blinkyQSto, Q_DIM(blinkyQSto), // event queue (void *)0, 0U); // stack (unused) return QF::run(); // run the QF application } 44
  • 45. QP/C++ (code example: blinky.cpp, 1) #include "qpcpp.h" #include "bsp.h" #include "blinky.h" class Blinky : public QActive { private: QTimeEvt m_timeEvt; public: Blinky(); protected: static QState initial(Blinky * const me, QEvt const * const e); static QState off(Blinky * const me, QEvt const * const e); static QState on(Blinky * const me, QEvt const * const e); }; Blinky l_blinky; QMActive * const AO_Blinky = &l_blinky; // opaque pointer 45
  • 46. QP/C++ (code example: blinky.cpp, 2) Blinky::Blinky() : QActive(Q_STATE_CAST(&Blinky::initial)), m_timeEvt(this, TIMEOUT_SIG, 0U) {} QState Blinky::initial(Blinky * const me, QEvt const * const e) { (void)e; // unused parameter // arm the time event to expire in half a second and every half second me->m_timeEvt.armX(BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U); return Q_TRAN(&Blinky::off); } 46
  • 47. QP/C++ (code example: blinky.cpp, 3) QState Blinky::off(Blinky * const me, QEvt const * const e) { QState status; switch (e->sig) { case Q_ENTRY_SIG: { BSP_ledOff(); status = Q_HANDLED(); break; } case TIMEOUT_SIG: { status = Q_TRAN(&Blinky::on); break; } default: { status = Q_SUPER(&QHsm::top); break; } } return status; } 47 QState Blinky::on(Blinky * const me, QEvt const * const e) { QState status; switch (e->sig) { case Q_ENTRY_SIG: { BSP_ledOn(); status = Q_HANDLED(); break; } case TIMEOUT_SIG: { status = Q_TRAN(&Blinky::off); break; } default: { status = Q_SUPER(&QHsm::top); break; } } return status; }
  • 48. Just::Thread Pro: Actors Edition http://www.stdthread.co.uk/pro/ C++11. Commercial license. Anthony Williams is the author. He wrote a famous book "C++ Concurrency in Action". This is almost all good news about this framework :) A separate OS thread is spawned for every actor :( 48
  • 49. Just::Thread Pro: Actors Edition (ping-pong) #include <jss/actor.hpp> #include <iostream> #include <thread> int main() { struct pingpong { jss::actor_ref sender; pingpong(jss::actor_ref sender_): sender(sender_) {} }; jss::actor pp1( []{ for(;;) { jss::actor::receive().match<pingpong>( [](pingpong p){ std::cout<<"pingn"; p.sender.send(pingpong(jss::actor::self())); }); } }); 49 jss::actor pp2( []{ for(;;) { jss::actor::receive().match<pingpong>( [](pingpong p){ std::cout<<"pongn"; p.sender.send(pingpong(jss::actor::self())); }); } }); pp1.send(pingpong(pp2)); std::this_thread::sleep_for(std::chrono::seconds(2)); pp1.stop(); pp2.stop(); }
  • 50. C++ Actor Framework (aka CAF) http://www.actor-framework.org/ C++11 or higher (the higher the better). OpenSource, BSD-3-CLAUSE or Boost licenses. Most PR-ed implementation of Actor Model for C++. Is positioned as very fast framework. But it can be discussed* ;) Is not stabilized yet. 50* Performance Comparison SO-5.5.15.2 vs CAF-0.14.4
  • 51. C++ Actor Framework (aka CAF) First versions of CAF copied Erlang as much as possible. But this is changed with time. The price for similarity to Erlang is high demands to standard conformance for C++ compilers. Support for Windows/VC++ was added only after Visual Studio 2015 update 3 release. Supports traditional async message-passing, request-reply and some kind of Pub/Sub. There is also support for distributed application (custom communication protocol on top of TCP/IP implemented via Boost::Asio). 51
  • 52. C++ Actor Framework (fixed_stack, 1) #include <cassert> #include <cstdint> #include <iostream> #include "caf/all.hpp" using std::endl; using namespace caf; namespace { using pop_atom = atom_constant<atom("pop")>; using push_atom = atom_constant<atom("push")>; enum class fixed_stack_errc : uint8_t { push_to_full = 1, pop_from_empty }; error make_error(fixed_stack_errc x) { return error{static_cast<uint8_t>(x), atom("FixedStack")}; } 52
  • 53. C++ Actor Framework (fixed_stack, 2) class fixed_stack : public event_based_actor { public: fixed_stack(actor_config& cfg, size_t stack_size) : event_based_actor(cfg), size_(stack_size) { full_.assign( [=](push_atom, int) -> error { return fixed_stack_errc::push_to_full; }, [=](pop_atom) -> int { auto result = data_.back(); data_.pop_back(); become(filled_); return result; } ); 53
  • 54. C++ Actor Framework (fixed_stack, 3) filled_.assign( [=](push_atom, int what) { data_.push_back(what); if (data_.size() == size_) become(full_); }, [=](pop_atom) -> int { auto result = data_.back(); data_.pop_back(); if (data_.empty()) become(empty_); return result; } ); 54
  • 55. C++ Actor Framework (fixed_stack, 4) empty_.assign( [=](push_atom, int what) { data_.push_back(what); become(filled_); }, [=](pop_atom) -> error { return fixed_stack_errc::pop_from_empty; } ); } 55
  • 56. C++ Actor Framework (fixed_stack, 5) behavior make_behavior() override { assert(size_ < 2); return empty_; } private: size_t size_; std::vector<int> data_; behavior full_; behavior filled_; behavior empty_; }; 56
  • 57. C++ Actor Framework (fixed_stack, 6) void caf_main(actor_system& system) { scoped_actor self{system}; auto st = self->spawn<fixed_stack>(5u); // fill stack for (int i = 0; i < 10; ++i) self->send(st, push_atom::value, i); // drain stack aout(self) << "stack: { "; bool stack_empty = false; while (!stack_empty) { self->request(st, std::chrono::seconds(10), pop_atom::value).receive( [&](int x) { aout(self) << x << " "; }, [&](const error&) { stack_empty = true; } ); } aout(self) << "}" << endl; self->send_exit(st, exit_reason::user_shutdown); } } // namespace <anonymous> CAF_MAIN() 57
  • 58. SObjectizer-5 https://sourceforge.net/projects/sobjectizer/ or https://github.com/eao197/so-5-5 C++11 (minimal: GCC 4.8, MSVC++12.0). OpenSource, BSD-3-CLAUSE license. Has very long story behind: 1995-2000: Homyel, Development Bureau of System Programming, SCADA Objectizer; 2002-...: Homyel-Moscow, Intervale, SObjectizer-4; 2010-...: Homyel-Moscow, Intervale and The SObjectizer Team, SObjectizer-5. 58
  • 59. SObjectizer-5 SO-4 in production since 2002. Still working. SO-5 in production since 2011. Backward compatibility – must have. We can't introduce breaking changes in every release. Simply can't. Version SO-5.5.0 was released in Oct 2014. There is no breaking changes in 5.5.* branch since then. The last stable version 5.5.18 is released in Sep 2016. 59
  • 60. SObjectizer-5 Actors in SO-5 are called agents. Agents in SO-5 are hierarchical finite automatas (nested states, enter/exit handlers, shallow- and deep-history, time limits). Working contexts for agents are provided by dispatchers. There are eight types of dispatchers available just "out of box". Distributed applications are not supported in SO-5. There was an experience in SO-4. Because of that we decided to use commodity tools which are appropriate for a specific task (MQTT, AMQP, HTTP and so on). 60
  • 61. SObjectizer-5 SO-5 is a symbiose of Actor Model, Publish/Subscribe and CSP* Messages are sent to a message box (mbox), not to a particular agent. There could be one agent behind a mbox. Or multiple agents. Or no one. Mbox is like a Topic in Pub/Sub. Message sending is like a Publish in Pub/Sub. Like in Pub/Sub an agent must be subscribed to the message to receive it. 61* https://en.wikipedia.org/wiki/Communicating_sequential_processes
  • 62. SObjectizer-5 (blinking_led, 1) #include <iostream> #include <so_5/all.hpp> class blinking_led final : public so_5::agent_t { state_t off{ this }, blinking{ this }, blink_on{ initial_substate_of{ blinking } }, blink_off{ substate_of{ blinking } }; public : struct turn_on_off : public so_5::signal_t {}; 62
  • 63. SObjectizer-5 (blinking_led, 2) blinking_led( context_t ctx ) : so_5::agent_t{ ctx } { this >>= off; off.just_switch_to< turn_on_off >( blinking ); blinking.just_switch_to< turn_on_off >( off ); blink_on .on_enter( []{ std::cout << "ON" << std::endl; } ) .on_exit( []{ std::cout << "off" << std::endl; } ) .time_limit( std::chrono::milliseconds{1250}, blink_off ); blink_off .time_limit( std::chrono::milliseconds{750}, blink_on ); } }; 63
  • 64. SObjectizer-5 (blinking_led, 3) int main() { so_5::launch( []( so_5::environment_t & env ) { so_5::mbox_t m; env.introduce_coop( [&]( so_5::coop_t & coop ) { auto led = coop.make_agent< blinking_led >(); m = led->so_direct_mbox(); } ); auto pause = []( unsigned int v ) { std::this_thread::sleep_for( std::chrono::seconds{v} ); }; so_5::send< blinking_led::turn_on_off >( m ); pause( 10 ); so_5::send< blinking_led::turn_on_off >( m ); pause( 5 ); so_5::send< blinking_led::turn_on_off >( m ); pause( 5 ); env.stop(); } ); } 64
  • 65. Conclusion 1/3 Actor Model is a great approach for cases where it can be used1 . It is proved many times in various projects where Erlang and Akka were successfully used. Someone said that async message-passing is the future. Just listen to Joe Armstrong, he knows what he says;) 1) Don't believe in an advertisement: it can be used not in every case. 65
  • 66. Conclusion 2/3 Our experience shows that there is sense in usage of Actor Model in C++. If you have an appropriate tool. There are already built and ready to use tools for C++. Very different tools. For different users. With different prices, of course. It is necessary to pay for usage of QP/C++ or Just::Thread Pro in a proprietary projects. SObjectizer and CAF can be used for free. 66
  • 67. Conclusion 3/3 It is a very bad idea to start the development of your own actor framework for C++. We have tried. It's a thankless job. Just believe us :) It is better to get something already existing. Hint: the name begins from SObj... ;) Just provide a chance to shoot oneself in a foot to developers of an actor framework. They enjoy it :) 67
  • 69. Bonus track (SO-5's fixed_stack, 1) #include <iostream> #include <so_5/all.hpp> class fixed_stack final : public so_5::agent_t { state_t st_empty{ this }, st_filled{ this }, st_full{ this }; const size_t m_max_size; std::vector< int > m_stack; public : class empty_stack final : public std::logic_error { public : using std::logic_error::logic_error; }; struct push { int m_val; }; struct pop : public so_5::signal_t {}; 69* https://bitbucket.org/sobjectizerteam/fixed_stack_example
  • 70. Bonus track (SO-5's fixed_stack, 2) fixed_stack( context_t ctx, size_t max_size ) : so_5::agent_t( ctx ) , m_max_size( max_size ) { this >>= st_empty; so_subscribe_self() .in( st_empty ) .in( st_filled ) .event( &fixed_stack::on_push ); so_subscribe_self() .in( st_filled ) .in( st_full ) .event( &fixed_stack::on_pop_when_not_empty ); so_subscribe_self() .in( st_empty ) .event( &fixed_stack::on_pop_when_empty ); } 70
  • 71. Bonus track (SO-5's fixed_stack, 3) private : void on_push( const push & w ) { m_stack.push_back( w.m_val ); this >>= ( m_stack.size() == m_max_size ? st_full : st_filled ); } int on_pop_when_not_empty( mhood_t< pop > ) { auto r = m_stack.back(); m_stack.pop_back(); this >>= ( m_stack.empty() ? st_empty : st_filled ); return r; } int on_pop_when_empty( mhood_t< pop > ) { throw empty_stack( "empty_stack" ); } }; 71
  • 72. Bonus track (SO-5's fixed_stack, 4) int main() { try { so_5::launch( []( so_5::environment_t & env ) { so_5::mbox_t stack; env.introduce_coop( [&stack]( so_5::coop_t & coop ) { stack = coop.make_agent< fixed_stack >( 5u )->so_direct_mbox(); } ); for( int i = 0; i < 10; ++i ) so_5::send< fixed_stack::push >( stack, i ); std::cout << "stack { "; try { for(;;) std::cout << so_5::request_value< int, fixed_stack::pop >( stack, std::chrono::seconds(10) ) << " "; } catch( const fixed_stack::empty_stack & ) {} std::cout << "}" << std::endl; env.stop(); } ); return 0; } catch( const std::exception & x ) { std::cerr << "Oops! " << x.what() << std::endl; } return 2; } 72
  • 73. SObjectizer Wiki: https://sourceforge.net/p/sobjectizer/wiki/Home/ Serie of slides "Dive into SObjectizer-5.5": Intro, Agent's States, More About Coops, Exceptions, Timers, Synchonous Interaction, Message Limits, Dispatchers, Message Chains. Author's blog: eao197.blogspot.com (in Russian) About SObjectizer in author's blog: eao197.blogspot.com/search/label/SObjectizer Author's email: eao197 at stiffstream com If you need a commercial support for SO-5: stiffstream.com 73