提高asio优先级和优先级 [英] Boost asio priority and strand

查看:180
本文介绍了提高asio优先级和优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对消息队列使用boost asio.我想对不同的对象执行不同的操作.操作具有优先权.因此,如果存在类型A的操作,则不应执行类型B的任何操作.据我了解,这就是boost dokumentation中优先级示例的作用.但是我同样需要的是,如果在一个对象中运行一个操作,我不想在同一个对象中执行另一操作.通过boost asio可以做到这一点吗?

I want to use boost asio for a message queue. I want to do different operations on different objects. The operations have a priority. So if there is a operation oft type A none of type B should be executed. To my understanding this is what the priority example in the boost dokumentation does. But what I as well need is, if there is one operation running in one object, i do not want to execute another operation in the same object. Is this something that can be done with boost asio?

推荐答案

后者与优先级排队无关,而与操作序列化无关.

The latter has nothing to do with priority queuing and everything with operation serialization.

您可以通过使用活动对象"模式来实现.这篇文章中提供了一个使用Asio的Active Object的示例: boost :: asio和活动对象

You can achieve this by using the Active Object pattern. An example of Active Object using Asio is in this post: boost::asio and Active Object

您可以简单地"将此模式与在示例中看到的用于优先级排队的模式相结合.

You can "simply" combine this pattern with the pattern for priority queuing that you saw in the example.

这篇关于提高asio优先级和优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆