boost-signals

Boost::signal memory access error

I'm trying to use boost::signal to implement a callback mechanism, and I'm getting a memory access assert in the boost::signal code on even the most trivial usage of the library. I have simplified it down to this code: #include <boost/signal.hpp> typedef boost::signal<void (void)> Event; int main(int argc, char* argv[]) { Event e...

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

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...

Public boost::signal object

I make my boost::signals public because I'm lazy. class Button { public: signal<void()> clicked; }; int main() { Button btn; btn.clicked.connect(handleClick); } ... rather than encapsulating with a Button::OnClicked(boost::function<void()>). Is this going to come back and bite me? ...

How to make a copyable boost::signal?

I get why boost::signal is noncopyable (it's because copying a signal doesn't have a clear meaning), but I need a version of it that does provide some sort of copy ctor (either a no-op or one that copies all connections). The reason I need this is because in my project many objects become noncopyable just by virtue of featuring signals,...

Complete example using Boost::Signals for C++ Eventing

I’m aware of the tutorial at boost.org addressing this Boost.org Signals Tutorial, but the examples are not complete and somewhat over simplified. I’m a C# programmer that got put on a C++ project so my C++ is a little rough. The examples there don’t show the include files and some sections of the code are a little vague for me. Here is...

Can I create a software watchdog timer thread in C++ using Boost Signals2 and Threads?

I am running function Foo from somebody else's library in a single-threaded application currently. Most of the time, I make a call to Foo and it's really quick, some times, I make a call to Foo and it takes forever. I am not a patient man, if Foo is going to take forever, I want to stop execution of Foo and not call it with those argum...

boost signal double free?

I'm having a hell of a time trying to debug some kind of memory access error, which I believe is a double free. The code is too complex to post, but I can try to describe it. Basically, I have two threads. When the worker thread is created, it instantiates a new boost::signal object, and stores it in a shared_ptr. The parent then querie...

Excluding boost signal calling

There is a signal and several objects with slots. I want to implement the behavior when one object calls signal and blocks its own connection. I guess a small snippet will be more informative: typedef boost::signal<void()> TSignal; template<class TSignal> class SlotObject { public: void Connect(boost::shared_ptr<TSignal> pSignal...

Memory leak using multiple boost::connect on single slot_type

Hi, I'm using boost::signals and leaking memory when I try to connect multiple signals to a single slot_type. I've seen this same leak reported on various forums, but can't find any that mention the correct way to do this, or any workaround. What I am trying to do: I am trying to pass the result of boost::bind() into a function. In th...

Boost: what could be the reasons for a crash in boost::slot<>::~slot ?

I am getting such a crash: #0 0x90b05955 in __gnu_debug::_Safe_iterator_base::_M_detach #1 0x90b059ce in __gnu_debug::_Safe_iterator_base::_M_attach #2 0x90b05afa in __gnu_debug::_Safe_sequence_base::_M_detach_all #3 0x000bc54f in __gnu_debug::_Safe_sequence_base::~_Safe_sequence_base at safe_base.h:170 #4 0x000aac05 in __gnu_debug...

Boost: what exactly is not threadsafe in Boost.Signals ?

I read at multiple places that Boost.Signals is not threadsafe but I haven't found much more details about it. This simple quote doesn't say really that much. Most applications nowadays have threads - even if they try to be single threaded, some of their libraries may use threads (for example libsdl). I guess the implementation doesn't ...

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

Hello, 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 ef...

How to achieve QT-like syntax of signal connections with Boost::Signal

In QT we can connect signals and slots using the following simple syntax: connect(pObject1, signal1, pObject2, slot2) For instance, one can write something like: A a; B b; connect(&a, SIGNAL(valueChanged(int)), &a, SLOT(setValue(int))); With Boost::Signal the syntax we would write it this way: A a; B b; a.valueChanged.conn...

How to raise a boost::signal whenever a packet is recieved?

I know that boost.asio has a mechanism that calls a callback function whenever a packet is received but is there an option to emit a signal instead? Do I have to write a function that emits the signal? If it is so, why? ...

Binding a member signal to a function

This line of code compiles correctly without a problem: boost::bind(boost::ref(connected_), boost::dynamic_pointer_cast<session<version> >(shared_from_this()), boost::asio::placeholders::error); However when assigning it to a boost::function or as a callback like this: socket_->async_connect(connection_->r...

How to prevent removal of slots from a certain signal?

Is it possible to block the removal of certain slots from a signal in the boost.signals library? If so how should a code that does such a thing will look like? Do I need to create a derived class just for that specific signal to do so? ...

How to convert an existing callback interface to use boost signals & slots

I've currently got a class that can notify a number of other objects via callbacks: class Callback { virtual NodulesChanged() =0; virtual TurkiesTwisted() =0; }; class Notifier { std::vector<Callback*> m_Callbacks; void AddCallback(Callback* cb) {m_Callbacks.push(cb); } ... void ChangeNodules() { for (iterator it=m...

segfault when using boost::signal with -D_GLIBCXX_DEBUG compiler flag

I'm building with g++, and yesterday a helpful person on SO told me to compile with the -D_GLIBCXX_DEBUG and -D_GLIBCXX_DEBUG_PEDANTIC flags. I did so, and I spent most of yesterday tweaking my code to conform to these flags. Now it's complaining about my use of boost::signal, and I'm not sure where the problem is. I have a class Yarl...

connecting a function to a boost::signal runs, but doesn't call the function

I have a class Yarl in my code with a member function refresh that I want to bind to two boost::signals. One of these signals is a member of a class EventHandler defined like this: class EventHandler { public: boost::signal<void()> sigRefresh; }; The other is a free floating signal in another file declared like this: nam...

std::tr1::function::target<TFuncPtr> and co-/contravariance

Since I love progamming in both C# and C++, I'm about to implementing a C#-like event system as a solid base for my planned C++ SFML-GUI. This is only an excerpt of my code and I hope this clarifies my concept: // Event.h // STL headers: #include <functional> #include <type_traits> #include <iostream> // boost headers: #include <boost/...