Event loop friendly C++ actor micro-framework
Ivan Baidakou a5ff8c9185 update docs | 1 ヶ月 前 | |
---|---|---|
.circleci | 1 年間 前 | |
cmake | 4 年 前 | |
docs | 1 ヶ月 前 | |
doxygen @ 6d9e60a262 | 1 ヶ月 前 | |
examples | 1 ヶ月 前 | |
include | 1 ヶ月 前 | |
src | 1 ヶ月 前 | |
test_package | 1 年間 前 | |
tests | 1 ヶ月 前 | |
.clang-format | 5 年 前 | |
.gitmodules | 5 年 前 | |
CMakeLists.txt | 1 ヶ月 前 | |
LICENSE | 5 年 前 | |
README.md | 1 ヶ月 前 | |
appveyor.yml | 1 ヶ月 前 | |
conanfile.py | 9 ヶ月 前 |
rotor
is event loop friendly C++ actor micro framework,
[github](https://github.com/basiliscos/cpp-rotor)
[abf](https://abf.io/basiliscos/cpp-rotor)
[gitee](https://gitee.com/basiliscos/cpp-rotor)
inter-thread (1) | cross-thread (2) | single thread (3) |
---|---|---|
~23.6M messages/second | ~ 2.5M messages/second | ~34.6М messages/second |
Setup: Intel Core i7-8550U, Void Linux 5.15.
(1) Backend-independent; Can be measured with examples/boost-asio/ping-pong-single-simple
, examples/ev/ping-pong-ev
.
(2) Does not apply to wx-backend; can be measured with examples/thread/ping-pong-thread
,
examples/boost-asio/ping-pong-2-threads
, examples/ev/ping-pong-ev-2-threads
.
(3) Backend-independent inter-thread messaging when build with BUILD_THREAD_UNSAFE=True
. rotor
objects (messages
and actors) cannot be accessed from different threads, cross-thread message sending facility cannot be used. This
option is mainly targeted for single-threaded apps.
MIT
Please read tutorial, design principles and manual here
Looking for something actor-flavored, but suitable for embedded applications? Take a look into my rotor-light project.
make_routed_message()
free function.
The function is used for "synchronized" message post-processing, i.e. once a
message has been delivered and processed by all recipients (can be zero),
then it is routed to the specifed address to do cleanup.Example:
std::string_view
s, owned by db)The make_routed_message
is needed to perform recipient-agnostic 3rd step.
The alternative is to create a copy (snapshot) of data (i.e. std::string
instead of std::string_view
), but that seems redundant.
void*
parameter to message_visitor_t
enable_fltk
option which add fltk-support/examples/ping-pong-fltk.cpp
and
examples/ping-pong-fltk_and_thread.cpp
bin
for cmakeactor_base_t::make_error()
is marked as constROTOR_INSPECT_DELIVERY=99
to see)message_visitor_t
message_stringifier_t
and the default implementation
default_stringifier_t
which allows to dump messages. It is not a production but
a diagnostic/debug tool, due to performance restrictions.system_context_t
provides a reference to default message_stringifier_t
;
it is possible to have a custom oneextended_error_t
holds a reference to a request message,
which caused an errorev
examples and testsexamples/thread/sha512.cpp
to use recent openssl
version3.15
start_timer
callback not only method, but any invocableenable_ev
option which add libev
boost
minimum version 1.83.0
catch2
from sources and make it dependenciescmake
minimum version 3.23
registry_t::revese_map_t revese_map
-> registry_t::reverse_map_t reverse_map
cancelation_t
-> cancellation_t
boost::unordered_map
instead of std::unordered_map
asio
and ev
loopsregistry_plugin_t
, allow to discover aliased services (#46)messages.cpp
on some platformsregistry
plugin for shared
library
on msvc-16+rotor
as shared libraryshutdown_finish
)rotor
under hood. I recommend to look at it, if the shipped examples are too-trivial, and
don't give you an architectural insight of using rotor
.rotor::thread
installationspawner
, which has a policy to auto-spawns
new actor instance if previous instance has been shutdown. This is similar to
escalate_failure supervising in erlang,
see dedicated articleautoshutdown_supervisor()
, when it shutdownescalate_failure()
, i.e. trigger shutdown own supervisor
when it finished with failureexamples/thread/ping-pong-spawner
(new)examples/autoshutdown
(new)examples/escalate-failure
(new)Design principles
Examples
Introduction
static_assert
for noexcept
check of a hanler signatureev
backendstd::thread
, boost-asio
and ev
backends (upto 5x times)extended_error
can now access to root reasonsystem_context
)examples/thread/ping-pong-thread.cpp
(new)examples/ev/ping-pong-ev-2-threads
(new)lifetime_plugin_t
do not unsubscribe from foreign to me subscriptionsforeigners_support_plugin_t
more safely deliver a message for a foreign
subscriber (actor)address_maker
pluginactor::do_shutdown()
- optionally takes shutdown reasonstd::error_code
the extended_error
class
is used. It wraps std::error_code
, provides string context and pointer to the next
extended_error
cause. This greatly simplifies error tracking of errors. Every response
now contains ee
field instead of ec
.actor
has shutdown reason (in form of extended_error
pointer)on_unlink
method to get it know, when it has been
unlinked from server actorresources
plugin for supervisorextended_error
pointer instead of std::error_code
shutdown_request_t
and shutdown_trigger_t
messages how have
shutdown reason (in form of extended_error
pointer)link_client_plugin_t
do not invoke custom callback, before erasing request
in case of failurechild_manager_plugin_t
reactivate self if a child was created from other
plugin.registry actor
incorrectly resolves postponed requests to wrong addressesstate_response_t
has been removedresources_plugin_t
, during
other plugin configurationstd::thread
backend (supervisor)examples/thread/sha512.cpp
(new)Event loops & platforms
Patterns
with Blocking I/O multiplexing
Advanced examples
,make_response
methods when message should be created, but
send later delayedexamples/boost-asio/ping-pong-timer.cpp
(new)examples/boost-asio/beast-scrapper.cpp
(updated)actor_config_t
was introduced, which now holds pointer to
supervisor, init and shutdown timeoutsbuilder
pattern was introduced to simplify actors constructionsupervisor_config_t
was changed (inherited from actor_config_t
)actor_base_t
and supervisor_t
constructors has changed - now
appropriate config is taken as single parameter. All descendant classes should
be changedconfig_t
inside the class, and templated config_builder_t
.supervisor_ev_t
not always correctly released EV-resources, which
lead to leakactor_base_t
can be shutted down properly even if it did not
started yetrotor::supervisor_t
and rotor::asio::supervisor_asio_t
rotor::asio::forwarder_t
now more correctly dispatches
boost::asio
events to actor methods; e.g. it works correctly now with
async_accept
method of socket_acceptor
supervisor_policy_t
was introduced to control supervisor
behavior on a child-actor startup failureexamples/ev/pong-registry.cpp
how to use registryrotor::arc_base
, to allow
forwarding requests without copying it (i.e. just intrusive pointer is created)examples/boost-asio/beast-scrapper.cpp
has been added; it
demonstrates an app with pool of actor workers with request-response forwardingsupervisor_config_t
,
which contains shutdown timeout valuecreate_actor
method now takes child max
init time value. If it does not confirm, the child actor will be asked
for shut down.message::shutdown_request_t
message::init_request_t
message::state_request_t
,
which follows the generic request/response pattern. The response type
is now message::state_response_t
.outbound
field in rotor::supervisor_t
was renamed just to queue
rotor::address_t
now contains const void*
localityrotor::asio::supervisor_config_t
now contains
std::shared_ptr
to strand
, instead of creating private strand
for each supervisordo_start()
method in rotor::supervisor_t
was
removed, since supervisor now is able to start self after completing
initialization.rotor::supervisor_t
sends initialize_actor_t
to self
to advance own state to INITIALIZED
via common actor mechanism,
instead of changing state directly on early initialization phase
(do_initialize
)rotor::asio::forwarder_t
now more correctly dispatches
boost::asio events to actor methodsrotor::ev::supervisor_ev_t
properly handles refcounter