如何用 ACE_Reactor 替换 WT 的主循环
我们有一个项目,其核心功能是使用 ACE 实现的,并围绕其 Reactor 进行架构设计。我们想使用 Wt 添加一个小型 Web 界面。
那么问题来了,wt接口的主循环是否可以用acereactor代替呢?
我想到的唯一坏主意是在 Reactor 端有一个快速计时器,它会以某种方式调用 wt 部分。 相反,反应器可以使用它的 handle_events 方法“逐个滴答”地运行,但我在 wt 方面找不到等效的方法。
笔记: 这个问题背后的主要关注点是关于线程。我们没有线程,代码不是线程安全的,如果 HMI 可以与应用程序的其余部分在同一线程上运行,那么对我们来说会简单得多。但是有 2 个阻塞调用,一个对 theReactor->run_reactor_event_loop(),另一个对 Wt::WRun() 是一个问题!
We have a project with a core functionality implemented using ACE, and architectured around it's Reactor. We want to add a small web interface using Wt.
So the question is, is it possible to replace the main loop of the wt interface with the ace reactor?
The only bad idea that comes to my mind is having a fast timer on the Reactor side which somehow invokes the wt part.
The other way round, the reactor can be run 'tick by tick' using it's handle_events method but I can't find an equivalent on the wt side.
note:
The main concern behind this question is about threads. We don't have threads, the code is not thread safe, and it would be a lot simpler for us if the HMI could be running on the same thread as the rest of the application. But having 2 blocking calls, one to theReactor->run_reactor_event_loop(), and the other to Wt::WRun() is a problem!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以通过对 Wt 连接器进行一些修改来实现。 Wt 可以在没有线程支持的情况下进行编译,因此在连接器中必须有某种 select() 循环。您需要的是能够使用计时器连接到该循环。
你说的是http连接器吗?这是用 boost.asio 实现的,因此一个带有执行 theReactor->run_reactor_event_loop() 的 async_wait 的 asio Deadline_timer 可能就是您所需要的。也许当您深入研究 boost.asio 文档时,您甚至可能会发现不同的想法......
它甚至可以在不修改连接器的情况下工作。它没有记录,但 Server::instance()->service() (在 src/http/Server.h 中)返回您实现此功能所需的 asio 服务。
更多信息-> Wt 的邮件列表?
That can work with some modifications to the Wt connector. Wt can be compiled without thread support, so in the connector there must be a select() loop of some kind. What you need is the ability to hook into that loop with a timer.
Are you talking about the http connector? That's implemented with boost.asio, so an asio deadline_timer with an async_wait that executes theReactor->run_reactor_event_loop() may be all you need. Maybe you may even find a different idea when you dive into the boost.asio documentation...
It could even work without modifications to the connector. It's not documented, but Server::instance()->service() (in src/http/Server.h) returns you the asio service that you need to implement this.
More info -> Wt's mailing list?