Questions tagged [boost-signals2]

The Boost.Signals2 library is a thread-safe C++ implementation of a managed signals and slots system.

The Boost.Signals2 library is a thread-safe C++ implementation of a managed signals and slots system. Signals represent callbacks with multiple targets, and are also called publishers or events in similar systems. Signals are connected to some set of slots, which are callback receivers (also called event targets or subscribers), which are called when the signal is "emitted."

Signals and slots are managed, in that signals and slots (or, more properly, objects that occur as part of the slots) can track connections and are capable of automatically disconnecting signal/slot connections when either is destroyed. This enables the user to make signal/slot connections without expending a great effort to manage the lifetimes of those connections with regard to the lifetimes of all objects involved.

When signals are connected to multiple slots, there is a question regarding the relationship between the return values of the slots and the return value of the signals. Boost.Signals2 allows the user to specify the manner in which multiple return values are combined.

109 questions
4
votes
4 answers

What is the point of Boost::Signals?

Firstly, I am an absolute beginner in programming, so don't make fun of me too much. The only thing that I have seen signals used for are GUI toolkits, and GUI toolkits all come with their own signaling. So, can Boost:Signals even be used with these…
Patrick
  • 1,894
  • 3
  • 15
  • 17
4
votes
1 answer

boost signals: Expose signal itself or connect / disconnect methods in class interface?

When having signals in a class, is it considered being good practice to expose the signal itself in the class "interface"? class MyClass { public: boost::signals2::signal& SomethingHappened() { return m_Signal; …
cdoubleplusgood
  • 1,309
  • 1
  • 11
  • 12
3
votes
1 answer

c++ boost signals 2

In c# we have the event keyword which is an special kind of delegate which can only be invoked from withing the class that declared it. So, is there a way of doing this in native c++ using boost::signals2, if so, is it expensive from a performance…
Yoss
  • 428
  • 6
  • 16
3
votes
3 answers

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

Consider this: #include #include struct object_with_slot { void operator()() { std::cout << "Slot called!" << std::endl; member = 50500; } int member; }; int main() { boost::signals2::signal
user1873947
  • 1,781
  • 3
  • 27
  • 47
3
votes
1 answer

C++ template param deduction is not working

I need to override connection between boost::signals2::signal and boost::function. For this purpose I've created following template function: template void bind(boost::signals2::signal &signal, boost::function function) { //…
3
votes
1 answer

Disconnecting a boost signals2 connection by functor

I'm trying to convert some code that used a different system over to use Boost.Signals2. The old code used a regular function pointer as the functor; connections were done by calling a particular method with the functor, and disconnections were…
Miral
  • 12,637
  • 4
  • 53
  • 93
3
votes
2 answers

Is there some Boost functionality for simulating a Glib::Dispatcher?

I am currently in the process of refactoring an mid-sized software project. It contains a central kernel-like class that is used by multiple threads. Currently, this class uses a Glib::Dispatcher for handling signals that are emitted by multiple…
Gnosophilon
  • 1,340
  • 7
  • 24
3
votes
2 answers

Handling a boost signal in Qt application with multiple threads

I have the following problem: Our main application uses the Qt toolkit for showing windows and user interaction. A large part of our application, however, is ignorant of the GUI part. I now created the following design: There is a singleton class…
Gnosophilon
  • 1,340
  • 7
  • 24
3
votes
1 answer

Error: "cannot access private member declared in class 'boost::signals2::scoped_connection'"?

class Whatever { public: virtual ~Whatever(); protected: Whatever(); virtual void SomeMethod(); void OnEventOccurred(int x); std::vector boostSignalConnections_; } //…
User
  • 62,498
  • 72
  • 186
  • 247
2
votes
1 answer

call boost signals2 slot on a separate thread

How can one call a boost signals2 slot on a separate thread without blocking the thread that is emitting the signal? I would like to get the functionality of the Qt5 QObject::connect with the QueuedConnection argument; for Qt5 details see Threads…
Phil
  • 5,822
  • 2
  • 31
  • 60
2
votes
2 answers

What is the prototype for Boost::signals2::signal::connect

I would like to encapsulate a signals2::signal object ans expose the connect and operator() functions, but how does their prototypes look like? Example: #include template class A { public: typedef…
Allan
  • 4,562
  • 8
  • 38
  • 59
2
votes
2 answers

Relaying a signal with boost.signals2

As can be seen in the code below (implemented as an illustration of the problem), I'm trying to send a signal from an inner class to a mid class, which will relay it to an outer class. #include #include #include…
ytm
  • 461
  • 1
  • 5
  • 16
2
votes
1 answer

In which thread are the slots executed?

Suppose I have four threads, with the following objects: Thread 1: manages a boost::signals2 object. Call it s. Thread 2: manages a X object and a reference to s. Call the X object o2. The member function X::do() is connected to s, to be executed…
ABu
  • 10,423
  • 6
  • 52
  • 103
2
votes
1 answer

'boost::detail::variant::visitation_impl': none of the 2 overloads could convert all the argument types

I'm not able to build two of my projects with Boost libraries 1.61.0 and Visual Studio 2015 Update 3. These projects used to build fine for years with various combinations of Visual Studio and Boost versions, and I didn't change anything in my code…
2
votes
3 answers

Wrap c++11 std::function in another std::function?

I'd like to wrap the result of a std::bind() or a lambda in a helper function that tracks the execution time of calls to the function. I'd like a generalized solution that will work with any number of parameters (and class methods) and is c++11…
moof2k
  • 1,678
  • 1
  • 17
  • 19