cpp-rotor

cpp-rotor

基于事件循环的高性能C++ Actor微框架

cpp-rotor是一个C++ Actor微框架,支持wx、Boost.Asio和libev等多种事件循环。它实现了Erlang式的分层监督、异步消息传递和请求-响应模式。该框架跨平台兼容Windows、macOS和Linux,拥有优异的消息吞吐性能。cpp-rotor适合开发响应式、可靠的应用,其设计参考了响应式宣言和SObjectizer项目的理念。

RotorC++actor框架事件循环消息传递Github开源项目

Rotor

rotor is event loop friendly C++ actor micro framework, github abf gitee

telegram CircleCI appveyor codecov Codacy Badge license

features

  • minimalistic loop agnostic core
  • erlang-like hierarchical supervisors, see this and this
  • various event loops supported (wx, boost-asio, ev) or planned (uv, gtk, etc.)
  • asynchronous message passing interface
  • request-response messaging with cancellation capabilities, see
  • MPMC (multiple producers multiple consumers) messaging, aka pub-sub
  • cross-platform (windows, macosx, linux)
  • inspired by The Reactive Manifesto and sobjectizer

messaging performance

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.

license

MIT

documentation

Please read tutorial, design principles and manual here

embedded

Looking for something actor-flavored, but suitable for embedded applications? Take a look into my rotor-light project.

Changelog

0.30 (23-Apr-2024)

  • [feature] added fltk-backend
  • [feature, conan] enable_fltk option which add fltk-support
  • [example] added /examples/ping-pong-fltk.cpp and examples/ping-pong-fltk_and_thread.cpp
  • [bugfix] wx-backend building and testing
  • [improvement, breaking] output directories are set to bin for cmake
  • [improvement, breaking] actor_base_t::make_error() is marked as const

0.29 (24-Feb-2024)

  • [bugfix] fix segfault in delivery plugin in debugging mode (try to set env ROTOR_INSPECT_DELIVERY=99 to see)

0.28 (22-Jan-2024)

  • [cmake, bugfix] add missing header into installation

0.27 (21-Jan-2024)

  • [feature] new interface message_visitor_t
  • [feature] new interface 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.
  • [feature] system_context_t provides a reference to default message_stringifier_t; it is possible to have a custom one
  • [feature, breaking] extended_error_t holds a reference to a request message, which caused an error
  • [examples, tests, win32] fix ev examples and tests
  • [example] modernize examples/thread/sha512.cpp to use recent openssl version
  • [breaking] cmake requirements are lowered to 3.15
  • [breaking] fix minor compilation warnings

0.26 (08-Jan-2024)

  • [feature] start_timer callback not only method, but any invocable
  • [feature, conan] enable_ev option which add libev
  • [breaking, conan] boost minimum version 1.83.0
  • [testing, conan] remove catch2 from sources and make it dependencies
  • [bugfix, breaking] make plugins more dll-friendly
  • [breaking] cmake minimum version 3.23
  • [breaking] rename registry_t::revese_map_t revese_map -> registry_t::reverse_map_t reverse_map
  • [breaking] rename struct cancelation_t -> cancellation_t
  • [doc] fix multiple typos

0.25 (26-Dec-2022)

  • [bugfix] avoid response messages loose their order relative to regular message
  • [bugfix, example] add missing header

0.24 (04-Jun-2022)

  • [feature] improve inter-thread messaging performance up to 15% by using boost::unordered_map instead of std::unordered_map
  • [bugfix, breaking] avoid introducing unnecessary event loops latency by intensive polling of rotor queues; affects asio and ev loops
  • [bugfix] registry_plugin_t, allow to discover aliased services (#46)

0.23 (23-Apr-2022)

  • [bugfix] fix compilation issues of messages.cpp on some platforms
  • [bugfix, msvc] fix compilation issues of registry plugin for shared library on msvc-16+

0.22 (21-Apr-2022)

  • [feature] possibly to install via conan center
  • [feature, breaking] possibility to build rotor as shared library
  • [feature] add shutdown flag checker (see my blog)
  • [bugfix] requests do not outlive actors (i.e. they are cancelled on shutdown_finish)
  • [example] there is my another open-source project syncspirit, which uses 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.

0.21 (25-Mar-2022)

  • [improvement] preliminary support of conan package manager
  • [bugfix] fix compilation warnings on Windows/MSVC
  • [bugfix] add missing header for rotor::thread installation

0.20 (20-Feb-2022)

  • [improvement] superviser can create spawner, 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 article
  • [improvement] actor can now autoshutdown_supervisor(), when it shutdown
  • [improvement] actor can now escalate_failure(), i.e. trigger shutdown own supervisor when it finished with failure
  • [improvement] messages delivery order is persevered per-locality (see issue #41)
  • [example] examples/thread/ping-pong-spawner (new)
  • [example] examples/autoshutdown (new)
  • [example] examples/escalate-failure (new)
  • [documentation] updated Design principles
  • [documentation] updated Examples
  • [documentation] updated Introduction

0.19 (31-Dec-2021)

  • [improvement] performance improvement in inter-thread (+20%) and cross-thread messaging
  • [bugfix] supervisor does not shut self down in rare conditions, when it fails to initialize self
  • [bugfix] link_server plugin should ignore unlink_notifications
  • [bugfix] avoid cycle (i.e. memleak) in rare cases when supervisor is shutdown, but an external message arrives for processing

0.18 (03-Dec-2021)

  • [improvement] add static_assert for noexcept check of a hanler signature
  • [improvement] add gitee mirror
  • [bugfix] fix potential use-after-free in ev backend

0.17 (23-Oct-2021)

  • [bugfix] fix installation issues with cmake (thanks to @melpon)
  • [bugfix] fix missing header (thanks to @melpon)
  • [ci] drop travis-ci in the sake of circle-ci

0.16 (22-Aug-2021)

  • [improvement] significant message throughtput increase for std::thread, boost-asio and ev backends (upto 5x times)
  • [improvement] extended_error can now access to root reason
  • [improvement] delivery plugin in debug mode dumps discovery requests and responses
  • [improvement/breaking] more details on fatal error (system_context)
  • [example] examples/thread/ping-pong-thread.cpp (new)
  • [example] examples/ev/ping-pong-ev-2-threads (new)

0.15 (02-Apr-2021)

  • [bugfix] lifetime_plugin_t do not unsubscribe from foreign to me subscriptions
  • [bugfix] foreigners_support_plugin_t more safely deliver a message for a foreign subscriber (actor)

0.14 (20-Feb-2021)

  • the dedicated article with highlights: en and ru
  • [improvement] actor identity has been introduced. It can be configured or generated via address_maker plugin
  • [improvement] actor::do_shutdown() - optionally takes shutdown reason
  • [improvement/breaking] instead of using std::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.
  • [improvement] actor has shutdown reason (in form of extended_error pointer)
  • [improvement] delivery plugin in debug mode it dumps shutdown reason in shutdown trigger messages
  • [improvement] actor identity has on_unlink method to get it know, when it has been unlinked from server actor
  • [improvement] add resources plugin for supervisor
  • [breaking] all responses now have extended_error pointer instead of std::error_code
  • [breaking] shutdown_request_t and shutdown_trigger_t messages how have shutdown reason (in form of extended_error pointer)
  • [bugfix] link_client_plugin_t do not invoke custom callback, before erasing request in case of failure
  • [bugfix] child_manager_plugin_t reactivate self if a child was created from other plugin.
  • [bugfix] registry actor incorrectly resolves postponed requests to wrong addresses

0.13 (26-Dec-2020)

  • [improvement] delivery plugin in debug mode dumps discarded messages
  • [breaking] state_response_t has been removed
  • [bugfix] allow to acquire & release resources in via resources_plugin_t, during other plugin configuration
  • [bugfix] foreigners_support_plugin_t did not deactivated self properly, caused assertion fail on supervisor shutdown, when there was foreign subscriptions
  • [bugfix] link_client_plugin_t did not notified linked server-actors, if its actor is going to shutdown; now server-actors are requested to unlink
  • [bugfix] starter_plugin_t sometimes crashed when subscription confirmation message arrives when actor is in non-initializing phase (i.e. shutting down)
  • [bugfix] root supervisor is not shutdown properly when it is linked as "server"

0.12 (08-Dec-2020)

  • [improvement] added std::thread backend (supervisor)
  • [bugfix] active timers, if any, are cancelled upon actor shutdown finish
  • [bugfix] supervisor shutdown message is lost in rare cases right after child actor start
  • [example] examples/thread/sha512.cpp (new)
  • [documentation] updated Event loops & platforms
  • [documentation] updated Patterns with Blocking I/O multiplexing
  • [deprecated] state_response_t, state_request_t will be removed in v0.13

0.11 (20-Nov-2020)

  • [improvement] when supervisor shuts self down due to child init failure, the supervisor init error code is "failure escalation"
  • [documentation] updated Advanced examples,
  • [bugfix] when actor shuts self down all its timers are properly cancelled
  • [bugfix] in rare case supervisor starts, event if child failed to init
  • [bugfix] asio: more correct timers cancellation implementation
  • [bugfix] ev: more correct shutdown (avoid memory leaks in rare cases)

0.10 (09-Nov-2020)

  • [improvement/breaking] Generic timers interface
  • [improvement] Request cancellation support
  • [improvement] added make_response methods when message should be created, but send later delayed
  • [improvement] more debug information in message delivery plugin
  • [documentation] Integration with event loops
  • [documentation] Requests cancellation and timers are demonstrated in the Advanced Examples section
  • [example] examples/boost-asio/ping-pong-timer.cpp (new)
  • [example] examples/boost-asio/beast-scrapper.cpp (updated)
  • [bugfix] avoid double configuration of a plugin in certain cases when interacting with resources plugin
  • [bugfix] more correct cmake installation (thanks to Jorge López Tello, @LtdJorge)

0.09 (03-Oct-2020)

  • the dedicated article with highlights: en and ru
  • [improvement] rewritten whole documentation
  • [improvement/breaking] plugin system where introduced for actors instead of behaviors
  • [improvement] actor_config_t was introduced, which now holds pointer to supervisor, init and shutdown timeouts
  • [improvement] builder pattern was introduced to simplify actors construction
  • [breaking] supervisor_config_t was changed (inherited from actor_config_t)
  • [breaking] actor_base_t and supervisor_t constructors has changed - now appropriate config is taken as single parameter. All descendant classes should be changed
  • [breaking] if a custom config type is used for actors/supervisors, they should define config_t inside the class, and templated config_builder_t.
  • [breaking] supervisor in actor is now accessible via pointer instead of reference
  • [bugfix] supervisor_ev_t not always correctly released EV-resources, which lead to leak
  • [bugfix]

编辑推荐精选

Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多