boost-signals

Signals vs Signals2

ぐ巨炮叔叔 提交于 2019-12-06 18:52:38
问题 I have application that may benefit from using one of boost's signals libraries over a homegrown solution. The application is multithreaded but the part that does the signal processing is single threaded. Is there any reason to prefer Boost.Signals2 over Boost.Signal if multithreading is not an issue? 回答1: Boost.Signals is now deprecated, and Boost.Signals2 should be used instead (see v1.54 docs) 回答2: Originally, if all the signals and slots were in the same thread, boost.signals was just

boost signals connection management

会有一股神秘感。 提交于 2019-12-05 03:31:23
问题 I've been bashing my head for the last two nights trying to figure this out with no positive results. There is the thing, in boost signals, every time I want to connect, say, a member function of one class to another's class signal, I have to save the resulting connection in a variable if I want to disconnect later. If later on, I want to connect the same member function to some other class signal (the member function is still connected with the previous class signal) I have to save this new

Signals vs Signals2

强颜欢笑 提交于 2019-12-05 00:07:01
I have application that may benefit from using one of boost's signals libraries over a homegrown solution. The application is multithreaded but the part that does the signal processing is single threaded. Is there any reason to prefer Boost.Signals2 over Boost.Signal if multithreading is not an issue? Boost.Signals is now deprecated, and Boost.Signals2 should be used instead (see v1.54 docs ) Originally, if all the signals and slots were in the same thread, boost.signals was just fine. However, it is no longer being maintained -- the documentation suggests using signals2 in all new code. 来源:

Is there a way to stop a boost::signal from calling its slots if one of them returns true?

旧街凉风 提交于 2019-12-04 18:06:32
I am using the boost library and my question is about boost::signals. I have a signal that might call many different slots but only one slot will match the call so I want this particular slot to return true and that the calling will stop. Is it possible? Is it efficient? Can you guys suggest me a better way to do it if it's not efficient? After some research I've found that in boost documentation they write about Slots that return values . They suggest to use a different combiner like this: struct breakIfTrue { template<typename InputIterator> bool operator()(InputIterator first, InputIterator

C++ member function pointer, boost::signals

混江龙づ霸主 提交于 2019-12-04 16:49:56
I have the following situation, (better in code) class Foo { private: typedef boost::signal<void ()> Signal; Signal signal; public: void Register_SignalFunction(const Signal::slot_type& slot); void Unregister_SignalFunction(const Signal::slog_type& slot); } class OtherFoo { Foo foo; public: OtherFoo() { foo.Register_SignalFunction(&OnSignal) //I know I can't do this that is precisely my question. } void OnSignal(); //what to do when signal fires } So the question is, how i pass a 'member-function' pointer to the Register method. Also, is this ok? What I want/need, is some sort of delegate

Boost::signals2 - descruction of an object with the slot

南楼画角 提交于 2019-12-01 23:39:49
Consider this: #include <boost/signals2.hpp> #include <iostream> struct object_with_slot { void operator()() { std::cout << "Slot called!" << std::endl; member = 50500; } int member; }; int main() { boost::signals2::signal<void ()> sig; object_with_slot * ptr = new object_with_slot; sig.connect(*ptr); delete ptr; sig(); } Output is "Slot called!" and no crash or anything. That's why I have a few questions: 1) Why there is no crash? 2) Why there is no crash even if the slot function assigns something to object which doesn't exist? 3) How can I make the signal automatically track the lifetime of

Does the boost.signals2 library need to be built?

老子叫甜甜 提交于 2019-12-01 00:46:53
My system is having trouble building the boost libraries. I understand that most boost libraries are (fortunately) just headers that do not need to be build (with some exceptions). Does the boost :: signals2 library need to be built? Also is the boost.signals2 library dependant on the boost.signals library? Signals is not header-only, signals2 is. But however, signals2 is explicitly developed for thread-safety and if you use boost.thread, this has to be compiled. As far as I know signals2 is not dependent on signals headers. No, signals2 is header only. See here . 来源: https://stackoverflow.com

Can not compile boost::signal tutorial using gcc 4.5 on ubuntu 11.04

自古美人都是妖i 提交于 2019-11-30 21:08:17
I'm trying to complete the boost::signal tutorial at http://www.boost.org/doc/libs/1_47_0/doc/html/signals/tutorial.html#id2850736 However Eclipse CDT shows parsing errors with whichever syntax I use I have #include <boost/signals.hpp> Preferred syntax boost::signal<void (float, float)> sig; sig.connect(&print_sum); Invalid template arguments at signal Method 'connect' could not be resolved Portable syntax boost::signal2<float, float, float> sig; sig.connect(&print_sum); Method 'connect' could not be resolved Symbol 'signal2' could not be resolved I use eclipse 3.7 It seems to be a CDT issue.

Can not compile boost::signal tutorial using gcc 4.5 on ubuntu 11.04

a 夏天 提交于 2019-11-30 04:49:24
问题 I'm trying to complete the boost::signal tutorial at http://www.boost.org/doc/libs/1_47_0/doc/html/signals/tutorial.html#id2850736 However Eclipse CDT shows parsing errors with whichever syntax I use I have #include <boost/signals.hpp> Preferred syntax boost::signal<void (float, float)> sig; sig.connect(&print_sum); Invalid template arguments at signal Method 'connect' could not be resolved Portable syntax boost::signal2<float, float, float> sig; sig.connect(&print_sum); Method 'connect'

How to use boost::bind in C++/CLI to bind a member of a managed class

为君一笑 提交于 2019-11-29 09:25:35
问题 I am using boost::signal in a native C++ class, and I now I am writing a .NET wrapper in C++/CLI, so that I can expose the native C++ callbacks as .NET events. When I try to use boost::bind to take the address of a member function of my managed class, I get compiler error 3374, saying I cannot take the address of a member function unless I am creating a delegate instance. Does anyone know how to bind a member function of a managed class using boost::bind? For clarification, the following