支持事件循环的 C++ 行为微框架,可监督
rotor is event loop friendly C++ actor micro framework,
sourcecraft
github
abf
| inter-thread (1) | cross-thread (2) | single thread (3) | no alloc, TS (4) | no alloc (5) |
|---|---|---|---|---|
| ~31.6M msgs/s | ~2.5M msgs/s | ~49.6М msgs/s | ~34.9M msgs/s | ~71.33M msgs/s |
Setup: Intel Core i7-1360P, Void Linux, 6.12.63
(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 ROTOR_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.
(4) Thread-safe pre-allocated single message inter-thread ping-pong'ing, see examples/thread/ping-pong-no-alloc.cpp
using redirect() technique intoduced in v0.36 .
(5) Thread-unsafe (ROTOR_BUILD_THREAD_UNSAFE=True) pre-allocated single message inter-thread ping-pong'ing,
see examples/thread/ping-pong-no-alloc.cpp using redirect() technique intoduced in v0.36 .
MIT
Please read tutorial, design principles and manual here
Looking for something actor-flavored, but suitable for embedded applications? Take a look into tardigrade project of my friend or rotor-light. To my opinion tardigrade is a bit better designed and should be considered first.
registry plugin during shutdownlink_client plugin during shutdownsupervisor during requests discardingexamples/thread/ping-pong-no-alloc.cpp
(use message redirection/no alloctions)compile_commands.json only if cmake version is >= 3.29
(more correct fix, thanks to @ErniGH)compile_commands.json only if cmake version is >= 3.293.15 -> 3.17route() and redirect() high-level actor methods, which
provide convenient API over make_routed_message() introduced in v0.32awakes after shutdown process, which leads
to minor memory leaksCMAKE_CURRENT_SOURCE_DIR instead of CMAKE_SOURCE_DIRBUILD_BOOST_ASIO => ROTOR_BUILD_ASIOBUILD_WX => ROTOR_BUILD_WXBUILD_EV => ROTOR_BUILD_EVBUILD_FLTK => ROTOR_BUILD_FLTKBUILD_THREAD => ROTOR_BUILD_THREADBUILD_DOC => ROTOR_BUILD_DOCBUILD_THREAD_UNSAFE => ROTOR_BUILD_THREAD_UNSAFEROTOR_BUILD_TESTS (instead of ENABLE_TESTING)ws2_32 lib for rotor_asio win32 buildmake_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_views, 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_tenable_fltk option which add fltk-support/examples/ping-pong-fltk.cpp and
examples/ping-pong-fltk_and_thread.cppbin for cmakeactor_base_t::make_error() is marked as constROTOR_INSPECT_DELIVERY=99 to see)message_visitor_tmessage_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.15start_timer callback not only method, but any invocableenable_ev option which add libevboost minimum version 1.83.0catch2 from sources and make it dependenciescmake minimum version 3.23registry_t::revese_map_t revese_map -> registry_t::reverse_map_t reverse_mapcancelation_t -> cancellation_tboost::unordered_map
instead of std::unordered_mapasio 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 principlesExamplesIntroduction暂无开放 Issues,或尚未同步最近议题。