其中C ++信号/插槽库,我应该选择? [英] Which C++ signals/slots library should I choose?

查看:164
本文介绍了其中C ++信号/插槽库,我应该选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不使用QT项目中使用一个信号/插槽库。我有pretty基本要求:

I want to use a signals/slots library in a project that doesn't use QT. I have pretty basic requirements:


  1. 连接两个函数与任意数量的参数。

  2. 信号可被连接到多个时隙。

  3. 信号/槽连接的手动断开。

  4. 不俗的表现 - 应用程序是基于帧的(即不是基于事件),我想用在每一帧的连接

我读过libsigc之间的比较++和Boost.Signals 的。我也看到了Boost.Signals从表现不佳受到影响。不过,我知道有其他图书馆,我仍然不知道我应该选择哪一个库。

I've read a comparison between libsigc++ and Boost.Signals. I've also read that Boost.Signals suffers from poor performance. However, I know there are other libraries and I'm still not sure which library should I choose.

是否有一个信号/插槽库的任何建议?

Are there any recommendations for a signals/slots library?

推荐答案

首先,尝试用升压::反正信号。不要以为它不会是速度不够快,直到你在特定的情况下,尝试是你的应用程序

First, try with boost::signal anyway. Don't assume it will not be fast enough until you try in your specific case that is your application

如果它不是足够有效的,可能像 FastDelegate 将满足您的需求? (我did'nt尝试,但听说这是在某些情况下很好的解决方案的boost ::信号似乎哪里不适合)。

If it's not efficient enough, maybe something like FastDelegate will suit your needs? (i did'nt try it but heard it was a nice solution in some cases where boost::signal don't seem to suit).

无论如何,如果你的应用程序中使用的信号每一帧,它可能是值得的东西更简单,比如持有对象/函子将被称为每一帧的容器更换信号系统。信号更提出让眼前的事件的管理比作一个循环周期动态(允许改变称为每一帧的功能)。
(我有我自己的解决方案我严重在一场比赛中使用,比如我已经没有任何问题的表现,也许类似的东西可能有所帮助)。

Anyway, if in your application use the signal each frame, it may be worth to replace the signal system by something more simple, like a container that hold objects/functors that will be called each frame. Signal is more made to allow immediate "events" management than to make a loop cycle dynamic (allowing changing the functions called each frame). (I have my own solution that i heavily use in a game and for instance i've no problem with the performance, so maybe something similar could help).

这篇关于其中C ++信号/插槽库,我应该选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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