SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
What is SObjectizer-5.5?
(at version 5.5.19)
SObjectizer Team, May 2017
SObjectizer is a small tool for simplification of development of
concurrent and event-driven applications in C++.
SObjectizer is responsible for:
● in-process message dispatching;
● providing working thread for message processing;
● SObjectizer Run-Time’s parameters tuning.
SObjectizer Team, May 2017
SObjectizer can be used for development of not only small
utilities but also of a large, distributed and highly loaded
software systems.
The whole application can be build upon SObjectizer.
Or SObjectizer can be used only as small part of an application
developed on the top of Qt, wxWidgets, ACE, Boost, etc.
SObjectizer Team, May 2017
SObjectizer allows to build a concurrent application as a set of
agent-objects which interact with each other only by means of
asynchronous messages.
SObjectizer was designed under the influence of several
approaches. And the Actor Model*
is one of them. But the
history of SObjectizer started long before this model became
widely known.
*
http://en.wikipedia.org/wiki/Actor_model SObjectizer Team, May 2017
SObjectizer’s main ideas and principles were formulated in the
middle of 1990s, during the development of SCADA Objectizer
project in Development Bureau of System Programming in
Homyel, Belarus (1996-2000).
SCADA Objectizer’s ideas were reused in the new project
SObjectizer-4 in 2002.
Evolution of SObjectizer-4 was stopped in 2010 and the
development of SObjectizer-5 started.
SObjectizer Team, May 2017
SObjectizer was an in-house project of JSC Intervale*
for the
long time.
SObjectizer was used in the development of the following
software systems:
● SMS/USSD traffic service;
● financial transaction handling;
● software parameters monitoring.
*
www.intervale.ru SObjectizer Team, May 2017
SObjectizer was published as an OpenSource project on
SourceForge under 3-clauses BSD-licence in 2006.
Since 2013 SObjectizer’s development completely moved to
SourceForge.
SObjectizer now is an independent project which a totally
separated from JSC Intervale.
SObjectizer Team, May 2017
SObjectizer-5 is developed using C++11 with broad usage of
C++11 standard library.
Supported platforms and compilers:
● Visual C++ 12.0/14.0/15.0, GCC 4.8-7.1, clang 3.9/4.0 on
Windows
● GCC 4.8-6.3, clang 3.4-4.0 on Linux, FreeBSD and MacOS;
● GCC 5.3, clang 3.7 on Android (via CrystaX NDK).
Support of other platforms is possible in the case when
SObjectizer’s developers will have an access to those platforms.
SObjectizer Team, May 2017
More than 20 releases of SObjectizer-5 were published since
May 2013.
The last stable version ‒ 5.5.19, was published in May 2017.
Version 5.5.19 is ~29 KLOC of SObjectizer core.
Plus ~33 KLOC of tests.
Plus ~10 KLOC of samples.
Plus SObjectizer’s core documentation*.
Plus articles and presentations** (some of them in Russian).
*
http://sourceforge.net/p/sobjectizer/wiki/Basics/
**
http://sourceforge.net/p/sobjectizer/wiki/Articles/ SObjectizer Team, May 2017
Using SObjectizer-5.5 a programmer must define
messages/signals and implement agents for processing them.
Agents are created by the programmer and are bound to
dispatchers. Dispatchers are responsible for message
dispatching and providing of working thread on which agents
handle messages.
SObjectizer Team, May 2017
SObjectizer has several ready-to-use dispatchers:
● one_thread. All agents work on a single working thread;
● active_obj. Every agent works on a single dedicated working thread;
● active_group. A single dedicated working thread is allocated for a group of
agents;
● thread_pool. A working thread is selected from thread pool. Agents can be
moved from one working thread to another. But an agent can’t work on two
threads at the same time;
● adv_thread_pool. A working thread is selected from thread pool. Agents can be
moved from one working thread to another. Moreover an agent can work on
several threads at the same time (if the agent’s event handlers are marked as
thread safe);
● prio_one_thread (strictly_ordered and quoted_round_robin). One working
thread and dispatching with respect to agent’s priorities;
● prio_dedicated_threads::one_per_prio. One working thread per a priority.
SObjectizer Team, May 2017
A programmer can create any number of dispatchers needed. This
allows to bind agents to different context in such a way that the impact
of one agent on another will be minimal. For example:
● one one_thread dispatcher for AMQP-client agent;
● one thread_pool dispatcher for handling requests from AMQP-queues;
● one active_obj dispatcher for DBMS-related agents;
● yet another active_obj dispatcher for agents whose work with HSMs
connected to the computer;
● and yet another thread_pool dispatcher for agents for managing all the
stuff described above.
SObjectizer Team, May 2017
A programmer can create as many agents as he needs.
Agent is a lightweight entity.
There could be thousands, millions and hundreds of millions of
agents.
Number of agents is limited only by amount of RAM and the
common sense of a programmer.
SObjectizer Team, May 2017
There is an SObjectizer example which demonstrates almost all
key features of SObjectizer-5.5:
● agent’s states,
● messages and signals,
● parent and children cooperations,
● dispatchers,
● delayed messages and so on...
SObjectizer Team, May 2017
Parent agent creates pinger and pointer agent pair. They do
message exchange for one second.
After one second the parent agent deregisters pinger and
ponger.
On finish pinger and ponger tell the parent how many
messages they received.
SObjectizer Team, May 2017
Example Code (signals and message definition):
#include <iostream>
#include <string>
// Main SObjectizer header file.
#include <so_5/all.hpp>
// Ping signal.
// Signal is a special kind of message without actual data.
// Sending of signals is like sending only atoms in Erlang.
struct ping : public so_5::signal_t {};
// Pong signal.
struct pong : public so_5::signal_t {};
// Message with result of pinger/ponger run.
// Unlike signal message must have actual data.
// Can be derived from so_5::message_t, but
// since v.5.5.9 it is not necessary.
struct run_result
{
std::string m_result;
};
SObjectizer Team, May 2017
Example Code (pinger agent, beginning):
// Pinger agent.
class pinger : public so_5::agent_t
{
public :
pinger( context_t ctx, so_5::mbox_t parent )
: so_5::agent_t{ ctx } // A working context.
, m_parent{ std::move(parent) } // Parent's mbox for result sending.
{}
// Ponger mbox will be available only after creation of pinger/ponger pair.
void set_ponger_mbox( const so_5::mbox_t & mbox ) { m_ponger = mbox; }
// This method is automatically called by SObjectizer during agent's registration procedure.
virtual void so_define_agent() override {
// Subscription for only one signal.
so_default_state().event< pong >( [this] {
++m_pongs;
so_5::send< ping >( m_ponger );
} );
}
SObjectizer Team, May 2017
Example Code (pinger agent, end):
// This method is automatically called by SObjectizer just after successful registration.
// Pinger uses this method to initiate message exchange.
virtual void so_evt_start() override {
// Sending signal by corresponding function.
so_5::send< ping >( m_ponger );
}
// This method is automatically called by SObjectizer just before deregistration of agent.
virtual void so_evt_finish() override {
// Sending result message by corresponding function.
so_5::send< run_result >(
// Receiver of the message.
m_parent,
// This will be forwarded to run_result's constructor.
"pongs: " + std::to_string( m_pongs ) );
}
private :
const so_5::mbox_t m_parent;
so_5::mbox_t m_ponger;
unsigned int m_pongs = 0;
};
SObjectizer Team, May 2017
Example Code (pоnger agent):
// Ponger agent is very similar to pinger. But it hasn't so_evt_start method
// because it will wait the first ping signal from the pinger.
// It also does subscription in the constructor (SObjectizer allows definition
// of subscriptions outside of so_define_agent method).
class ponger : public so_5::agent_t {
public :
ponger(context_t ctx, so_5::mbox_t parent)
: so_5::agent_t{ctx}, m_parent{std::move(parent)}
{
so_default_state().event< ping >( [this]{
++m_pings;
so_5::send< pong >( m_pinger );
} );
}
void set_pinger_mbox( const so_5::mbox_t & mbox ) { m_pinger = mbox; }
virtual void so_evt_finish() override {
so_5::send< run_result >( m_parent, "pings: " + std::to_string( m_pings ) );
}
private :
const so_5::mbox_t m_parent;
so_5::mbox_t m_pinger;
unsigned int m_pings = 0;
};
SObjectizer Team, May 2017
Example Code (parent agent, beginning):
// Parent agent.
// Creates pair of pinger/ponger agents, then limits their working time,
// then handles their run results.
class parent : public so_5::agent_t
{
private :
// Time limit signal.
struct stop : public so_5::signal_t {};
// Additional state for the agent.
// This state means that the first result from children agents
// has been received and that the parent expects the last one.
const so_5::state_t st_first_result_got{ this };
// Result's accumulator.
std::string m_results;
public :
parent( context_t ctx )
: so_5::agent_t{ ctx }
{}
SObjectizer Team, May 2017
Example Code (parent agent, continued-1):
virtual void so_define_agent() override {
// Arriving of time limit signal means that
// child cooperation must be deregistered.
so_default_state().event< stop >( [this] {
so_environment().deregister_coop(
// Name of cooperation for deregistration.
"pinger_ponger",
// The reason of deregistration,
// this value means that deregistration is caused
// by application logic.
so_5::dereg_reason::normal );
} );
// NOTE: type of message is automatically deduced from
// event handlers signatures.
// First result will be received in default state.
so_default_state().event( &parent::evt_first_result );
// But the second one will be received in next state.
st_first_result_got.event( &parent::evt_second_result );
}
SObjectizer Team, May 2017
Example Code (parent agent, continued-2):
virtual void so_evt_start() {
// Creation of child cooperation with pinger and ponger.
so_5::introduce_child_coop(
*this, // Parent of the new coop.
"pinger_ponger", // Name of child coop.
// Child cooperation will use active_obj dispatcher.
// So pinger and ponger will work on the different working threads.
so_5::disp::active_obj::create_private_disp( so_environment() )->binder(),
[&]( so_5::coop_t & coop )
{
// Filling the child cooperation.
auto a_pinger = coop.make_agent< pinger >(so_direct_mbox());
auto a_ponger = coop.make_agent< ponger >(so_direct_mbox());
a_pinger->set_ponger_mbox( a_ponger->so_direct_mbox() );
a_ponger->set_pinger_mbox( a_pinger->so_direct_mbox() );
} );
// Limit the pinger/ponger exchange time.
so_5::send_delayed< stop >( *this, std::chrono::seconds( 1 ) );
}
SObjectizer Team, May 2017
Example Code (parent agent, end):
private :
// Event handler for the first result.
void evt_first_result( const run_result & evt ) {
m_results = evt.m_result + "; ";
// State of the agent must be changed.
this >>= st_first_result_got;
}
// Event handler for the next (and last) result.
void evt_second_result( const run_result & evt ) {
m_results += evt.m_result;
// Show the results and finish work.
std::cout << m_results << std::endl;
// This is deregistration of the last live cooperation.
// SO Environment will finish its work.
so_deregister_agent_coop_normally();
}
};
SObjectizer Team, May 2017
Example Code (main function):
int main()
{
try
{
// Create SO Environment objects and run SO Run-Time inside it.
so_5::launch(
// SO Environment initialization routine.
[]( so_5::environment_t & env )
{
// We must have the cooperation with just one agent inside it.
// The name for the cooperation will be generated automatically.
env.introduce_coop( []( so_5::coop_t & coop ) {
// The single agent in the cooperation.
coop.make_agent< parent >();
} );
} );
}
catch( const std::exception & x )
{
std::cerr << "Exception: " << x.what() << std::endl;
}
}
SObjectizer Team, May 2017
Result:
pongs: 1005040; pings: 1005041
Just about 2M messages per seconds with the exchange by a
single message between two different threads (pinger and
ponger work on different threads).
Core i7 2.4GHz, 8GiB RAM, Win8.1 64-bit,
Visual C++ 2013 64-bit
SObjectizer Team, May 2017
Additional Information:
Project’s home: http://sourceforge.net/projects/sobjectizer
Documentation: http://sourceforge.net/p/sobjectizer/wiki/
Forum: http://sourceforge.net/p/sobjectizer/discussion/
Google-group: https://groups.google.com/forum/#!forum/sobjectizer
Support: https://stiffstream.com

Contenu connexe

Tendances

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
 
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
 
Heading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th CheckHeading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th CheckPVS-Studio
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answerssheibansari
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in PracticeAlina Dolgikh
 
Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaDenilson Nastacio
 
"Node.js threads for I/O-bound tasks", Timur Shemsedinov
"Node.js threads for I/O-bound tasks", Timur Shemsedinov"Node.js threads for I/O-bound tasks", Timur Shemsedinov
"Node.js threads for I/O-bound tasks", Timur ShemsedinovFwdays
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSPVS-Studio
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptKaty Slemon
 
Concurrency in Programming Languages
Concurrency in Programming LanguagesConcurrency in Programming Languages
Concurrency in Programming LanguagesYudong Li
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеSergey Platonov
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals ThreadsNeera Mital
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkMicha Kops
 
Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기Taehwan kwon
 

Tendances (20)

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
 
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
 
Heading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th CheckHeading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th Check
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answers
 
C++ references
C++ referencesC++ references
C++ references
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Java Concurrency in Practice
Java Concurrency in PracticeJava Concurrency in Practice
Java Concurrency in Practice
 
Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for Java
 
"Node.js threads for I/O-bound tasks", Timur Shemsedinov
"Node.js threads for I/O-bound tasks", Timur Shemsedinov"Node.js threads for I/O-bound tasks", Timur Shemsedinov
"Node.js threads for I/O-bound tasks", Timur Shemsedinov
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMS
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescript
 
04 threads
04 threads04 threads
04 threads
 
Concurrency in Programming Languages
Concurrency in Programming LanguagesConcurrency in Programming Languages
Concurrency in Programming Languages
 
Complete Java Course
Complete Java CourseComplete Java Course
Complete Java Course
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals Threads
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기Kotlin으로 안드로이드 개발하기
Kotlin으로 안드로이드 개발하기
 

Similaire à What is SObjectizer 5.5

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
 
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
 
Essential Tools for Modern PHP
Essential Tools for Modern PHPEssential Tools for Modern PHP
Essential Tools for Modern PHPAlex Weissman
 
ROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor HelicoptersROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor HelicoptersAtılay Mayadağ
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCTim Burks
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdfBOSC Tech Labs
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom componentsJeremy Grancher
 
DevOps Automation with Puppet Bolt & Puppet Enterprise
DevOps Automation with Puppet Bolt & Puppet EnterpriseDevOps Automation with Puppet Bolt & Puppet Enterprise
DevOps Automation with Puppet Bolt & Puppet EnterpriseEficode
 
Get started with meteor | designveloper software agency meteor prime partner
Get started with meteor | designveloper software agency   meteor prime partnerGet started with meteor | designveloper software agency   meteor prime partner
Get started with meteor | designveloper software agency meteor prime partnerDesignveloper
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Andrey Karpov
 
zJOS - Mainframe Automation Solution
zJOS - Mainframe Automation SolutionzJOS - Mainframe Automation Solution
zJOS - Mainframe Automation SolutionDeru Sudibyo
 

Similaire à What is SObjectizer 5.5 (20)

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)
 
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
 
Essential Tools for Modern PHP
Essential Tools for Modern PHPEssential Tools for Modern PHP
Essential Tools for Modern PHP
 
resume
resumeresume
resume
 
ROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor HelicoptersROS Based Programming and Visualization of Quadrotor Helicopters
ROS Based Programming and Visualization of Quadrotor Helicopters
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom components
 
CityEngine-OpenDS
CityEngine-OpenDSCityEngine-OpenDS
CityEngine-OpenDS
 
Mini-Training: TypeScript
Mini-Training: TypeScriptMini-Training: TypeScript
Mini-Training: TypeScript
 
DevOps Automation with Puppet Bolt & Puppet Enterprise
DevOps Automation with Puppet Bolt & Puppet EnterpriseDevOps Automation with Puppet Bolt & Puppet Enterprise
DevOps Automation with Puppet Bolt & Puppet Enterprise
 
Get started with meteor | designveloper software agency meteor prime partner
Get started with meteor | designveloper software agency   meteor prime partnerGet started with meteor | designveloper software agency   meteor prime partner
Get started with meteor | designveloper software agency meteor prime partner
 
Rock Overview
Rock OverviewRock Overview
Rock Overview
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 
Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#Analysis of merge requests in GitLab using PVS-Studio for C#
Analysis of merge requests in GitLab using PVS-Studio for C#
 
zJOS - Mainframe Automation Solution
zJOS - Mainframe Automation SolutionzJOS - Mainframe Automation Solution
zJOS - Mainframe Automation Solution
 
Meet with Meteor
Meet with MeteorMeet with Meteor
Meet with Meteor
 
Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
 

Plus de Yauheni Akhotnikau

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
 
[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
 
Actor Model and C++: what, why and how?
Actor Model and C++: what, why and how?Actor Model and C++: what, why and how?
Actor Model and C++: what, why and how?Yauheni Akhotnikau
 
Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++Yauheni Akhotnikau
 
Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?Yauheni Akhotnikau
 
Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?Yauheni 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
 
Погружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная частьПогружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная частьYauheni Akhotnikau
 

Plus de Yauheni Akhotnikau (14)

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)
 
[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
 
Actor Model and C++: what, why and how?
Actor Model and C++: what, why and how?Actor Model and C++: what, why and how?
Actor Model and C++: what, why and how?
 
Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++Шишки, набитые за 15 лет использования акторов в C++
Шишки, набитые за 15 лет использования акторов в C++
 
Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?Для чего мы делали свой акторный фреймворк и что из этого вышло?
Для чего мы делали свой акторный фреймворк и что из этого вышло?
 
Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?Модель акторов и C++ что, зачем и как?
Модель акторов и C++ что, зачем и как?
 
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
 
Погружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная частьПогружение в SObjectizer 5.5. Вводная часть
Погружение в SObjectizer 5.5. Вводная часть
 
Обзор SObjectizer 5.5
Обзор SObjectizer 5.5Обзор SObjectizer 5.5
Обзор SObjectizer 5.5
 

Dernier

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 

Dernier (20)

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 

What is SObjectizer 5.5

  • 1. What is SObjectizer-5.5? (at version 5.5.19) SObjectizer Team, May 2017
  • 2. SObjectizer is a small tool for simplification of development of concurrent and event-driven applications in C++. SObjectizer is responsible for: ● in-process message dispatching; ● providing working thread for message processing; ● SObjectizer Run-Time’s parameters tuning. SObjectizer Team, May 2017
  • 3. SObjectizer can be used for development of not only small utilities but also of a large, distributed and highly loaded software systems. The whole application can be build upon SObjectizer. Or SObjectizer can be used only as small part of an application developed on the top of Qt, wxWidgets, ACE, Boost, etc. SObjectizer Team, May 2017
  • 4. SObjectizer allows to build a concurrent application as a set of agent-objects which interact with each other only by means of asynchronous messages. SObjectizer was designed under the influence of several approaches. And the Actor Model* is one of them. But the history of SObjectizer started long before this model became widely known. * http://en.wikipedia.org/wiki/Actor_model SObjectizer Team, May 2017
  • 5. SObjectizer’s main ideas and principles were formulated in the middle of 1990s, during the development of SCADA Objectizer project in Development Bureau of System Programming in Homyel, Belarus (1996-2000). SCADA Objectizer’s ideas were reused in the new project SObjectizer-4 in 2002. Evolution of SObjectizer-4 was stopped in 2010 and the development of SObjectizer-5 started. SObjectizer Team, May 2017
  • 6. SObjectizer was an in-house project of JSC Intervale* for the long time. SObjectizer was used in the development of the following software systems: ● SMS/USSD traffic service; ● financial transaction handling; ● software parameters monitoring. * www.intervale.ru SObjectizer Team, May 2017
  • 7. SObjectizer was published as an OpenSource project on SourceForge under 3-clauses BSD-licence in 2006. Since 2013 SObjectizer’s development completely moved to SourceForge. SObjectizer now is an independent project which a totally separated from JSC Intervale. SObjectizer Team, May 2017
  • 8. SObjectizer-5 is developed using C++11 with broad usage of C++11 standard library. Supported platforms and compilers: ● Visual C++ 12.0/14.0/15.0, GCC 4.8-7.1, clang 3.9/4.0 on Windows ● GCC 4.8-6.3, clang 3.4-4.0 on Linux, FreeBSD and MacOS; ● GCC 5.3, clang 3.7 on Android (via CrystaX NDK). Support of other platforms is possible in the case when SObjectizer’s developers will have an access to those platforms. SObjectizer Team, May 2017
  • 9. More than 20 releases of SObjectizer-5 were published since May 2013. The last stable version ‒ 5.5.19, was published in May 2017. Version 5.5.19 is ~29 KLOC of SObjectizer core. Plus ~33 KLOC of tests. Plus ~10 KLOC of samples. Plus SObjectizer’s core documentation*. Plus articles and presentations** (some of them in Russian). * http://sourceforge.net/p/sobjectizer/wiki/Basics/ ** http://sourceforge.net/p/sobjectizer/wiki/Articles/ SObjectizer Team, May 2017
  • 10. Using SObjectizer-5.5 a programmer must define messages/signals and implement agents for processing them. Agents are created by the programmer and are bound to dispatchers. Dispatchers are responsible for message dispatching and providing of working thread on which agents handle messages. SObjectizer Team, May 2017
  • 11. SObjectizer has several ready-to-use dispatchers: ● one_thread. All agents work on a single working thread; ● active_obj. Every agent works on a single dedicated working thread; ● active_group. A single dedicated working thread is allocated for a group of agents; ● thread_pool. A working thread is selected from thread pool. Agents can be moved from one working thread to another. But an agent can’t work on two threads at the same time; ● adv_thread_pool. A working thread is selected from thread pool. Agents can be moved from one working thread to another. Moreover an agent can work on several threads at the same time (if the agent’s event handlers are marked as thread safe); ● prio_one_thread (strictly_ordered and quoted_round_robin). One working thread and dispatching with respect to agent’s priorities; ● prio_dedicated_threads::one_per_prio. One working thread per a priority. SObjectizer Team, May 2017
  • 12. A programmer can create any number of dispatchers needed. This allows to bind agents to different context in such a way that the impact of one agent on another will be minimal. For example: ● one one_thread dispatcher for AMQP-client agent; ● one thread_pool dispatcher for handling requests from AMQP-queues; ● one active_obj dispatcher for DBMS-related agents; ● yet another active_obj dispatcher for agents whose work with HSMs connected to the computer; ● and yet another thread_pool dispatcher for agents for managing all the stuff described above. SObjectizer Team, May 2017
  • 13. A programmer can create as many agents as he needs. Agent is a lightweight entity. There could be thousands, millions and hundreds of millions of agents. Number of agents is limited only by amount of RAM and the common sense of a programmer. SObjectizer Team, May 2017
  • 14. There is an SObjectizer example which demonstrates almost all key features of SObjectizer-5.5: ● agent’s states, ● messages and signals, ● parent and children cooperations, ● dispatchers, ● delayed messages and so on... SObjectizer Team, May 2017
  • 15. Parent agent creates pinger and pointer agent pair. They do message exchange for one second. After one second the parent agent deregisters pinger and ponger. On finish pinger and ponger tell the parent how many messages they received. SObjectizer Team, May 2017
  • 16. Example Code (signals and message definition): #include <iostream> #include <string> // Main SObjectizer header file. #include <so_5/all.hpp> // Ping signal. // Signal is a special kind of message without actual data. // Sending of signals is like sending only atoms in Erlang. struct ping : public so_5::signal_t {}; // Pong signal. struct pong : public so_5::signal_t {}; // Message with result of pinger/ponger run. // Unlike signal message must have actual data. // Can be derived from so_5::message_t, but // since v.5.5.9 it is not necessary. struct run_result { std::string m_result; }; SObjectizer Team, May 2017
  • 17. Example Code (pinger agent, beginning): // Pinger agent. class pinger : public so_5::agent_t { public : pinger( context_t ctx, so_5::mbox_t parent ) : so_5::agent_t{ ctx } // A working context. , m_parent{ std::move(parent) } // Parent's mbox for result sending. {} // Ponger mbox will be available only after creation of pinger/ponger pair. void set_ponger_mbox( const so_5::mbox_t & mbox ) { m_ponger = mbox; } // This method is automatically called by SObjectizer during agent's registration procedure. virtual void so_define_agent() override { // Subscription for only one signal. so_default_state().event< pong >( [this] { ++m_pongs; so_5::send< ping >( m_ponger ); } ); } SObjectizer Team, May 2017
  • 18. Example Code (pinger agent, end): // This method is automatically called by SObjectizer just after successful registration. // Pinger uses this method to initiate message exchange. virtual void so_evt_start() override { // Sending signal by corresponding function. so_5::send< ping >( m_ponger ); } // This method is automatically called by SObjectizer just before deregistration of agent. virtual void so_evt_finish() override { // Sending result message by corresponding function. so_5::send< run_result >( // Receiver of the message. m_parent, // This will be forwarded to run_result's constructor. "pongs: " + std::to_string( m_pongs ) ); } private : const so_5::mbox_t m_parent; so_5::mbox_t m_ponger; unsigned int m_pongs = 0; }; SObjectizer Team, May 2017
  • 19. Example Code (pоnger agent): // Ponger agent is very similar to pinger. But it hasn't so_evt_start method // because it will wait the first ping signal from the pinger. // It also does subscription in the constructor (SObjectizer allows definition // of subscriptions outside of so_define_agent method). class ponger : public so_5::agent_t { public : ponger(context_t ctx, so_5::mbox_t parent) : so_5::agent_t{ctx}, m_parent{std::move(parent)} { so_default_state().event< ping >( [this]{ ++m_pings; so_5::send< pong >( m_pinger ); } ); } void set_pinger_mbox( const so_5::mbox_t & mbox ) { m_pinger = mbox; } virtual void so_evt_finish() override { so_5::send< run_result >( m_parent, "pings: " + std::to_string( m_pings ) ); } private : const so_5::mbox_t m_parent; so_5::mbox_t m_pinger; unsigned int m_pings = 0; }; SObjectizer Team, May 2017
  • 20. Example Code (parent agent, beginning): // Parent agent. // Creates pair of pinger/ponger agents, then limits their working time, // then handles their run results. class parent : public so_5::agent_t { private : // Time limit signal. struct stop : public so_5::signal_t {}; // Additional state for the agent. // This state means that the first result from children agents // has been received and that the parent expects the last one. const so_5::state_t st_first_result_got{ this }; // Result's accumulator. std::string m_results; public : parent( context_t ctx ) : so_5::agent_t{ ctx } {} SObjectizer Team, May 2017
  • 21. Example Code (parent agent, continued-1): virtual void so_define_agent() override { // Arriving of time limit signal means that // child cooperation must be deregistered. so_default_state().event< stop >( [this] { so_environment().deregister_coop( // Name of cooperation for deregistration. "pinger_ponger", // The reason of deregistration, // this value means that deregistration is caused // by application logic. so_5::dereg_reason::normal ); } ); // NOTE: type of message is automatically deduced from // event handlers signatures. // First result will be received in default state. so_default_state().event( &parent::evt_first_result ); // But the second one will be received in next state. st_first_result_got.event( &parent::evt_second_result ); } SObjectizer Team, May 2017
  • 22. Example Code (parent agent, continued-2): virtual void so_evt_start() { // Creation of child cooperation with pinger and ponger. so_5::introduce_child_coop( *this, // Parent of the new coop. "pinger_ponger", // Name of child coop. // Child cooperation will use active_obj dispatcher. // So pinger and ponger will work on the different working threads. so_5::disp::active_obj::create_private_disp( so_environment() )->binder(), [&]( so_5::coop_t & coop ) { // Filling the child cooperation. auto a_pinger = coop.make_agent< pinger >(so_direct_mbox()); auto a_ponger = coop.make_agent< ponger >(so_direct_mbox()); a_pinger->set_ponger_mbox( a_ponger->so_direct_mbox() ); a_ponger->set_pinger_mbox( a_pinger->so_direct_mbox() ); } ); // Limit the pinger/ponger exchange time. so_5::send_delayed< stop >( *this, std::chrono::seconds( 1 ) ); } SObjectizer Team, May 2017
  • 23. Example Code (parent agent, end): private : // Event handler for the first result. void evt_first_result( const run_result & evt ) { m_results = evt.m_result + "; "; // State of the agent must be changed. this >>= st_first_result_got; } // Event handler for the next (and last) result. void evt_second_result( const run_result & evt ) { m_results += evt.m_result; // Show the results and finish work. std::cout << m_results << std::endl; // This is deregistration of the last live cooperation. // SO Environment will finish its work. so_deregister_agent_coop_normally(); } }; SObjectizer Team, May 2017
  • 24. Example Code (main function): int main() { try { // Create SO Environment objects and run SO Run-Time inside it. so_5::launch( // SO Environment initialization routine. []( so_5::environment_t & env ) { // We must have the cooperation with just one agent inside it. // The name for the cooperation will be generated automatically. env.introduce_coop( []( so_5::coop_t & coop ) { // The single agent in the cooperation. coop.make_agent< parent >(); } ); } ); } catch( const std::exception & x ) { std::cerr << "Exception: " << x.what() << std::endl; } } SObjectizer Team, May 2017
  • 25. Result: pongs: 1005040; pings: 1005041 Just about 2M messages per seconds with the exchange by a single message between two different threads (pinger and ponger work on different threads). Core i7 2.4GHz, 8GiB RAM, Win8.1 64-bit, Visual C++ 2013 64-bit SObjectizer Team, May 2017
  • 26. Additional Information: Project’s home: http://sourceforge.net/projects/sobjectizer Documentation: http://sourceforge.net/p/sobjectizer/wiki/ Forum: http://sourceforge.net/p/sobjectizer/discussion/ Google-group: https://groups.google.com/forum/#!forum/sobjectizer Support: https://stiffstream.com