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
2
votes
2 answers

Connect pointer to boost::signals2

I was wondering if somehow it was possible to connect a pointer to a boost::signals2::signal. For my problem is the following : I want the object connected to the "signal" to be changed. For instance : class Something { public: int x; …
Nicolas Mattia
  • 1,269
  • 11
  • 20
2
votes
1 answer

Safely disconnecting from boost::signals2

With boost signals (which is now deprecated) I always wrapped connection management and signal invocation with a mutex in order to be thread-safe. Boost signals 2 should give that out-of-the-box. But: According to the Boost Signals2 Thread-Safety…
Manuel Barbe
  • 2,104
  • 16
  • 21
2
votes
1 answer

Boost::signals2 - Passing a signal slot as argument

I'm using boost::signals2 to create a class that uses a signal to run an event under a specific condition. This class has a method that is called: RegisterCallback. This function should take a parameter of the slot type that the signal uses (which…
Oyvind Andersson
  • 362
  • 6
  • 22
2
votes
2 answers

Boost.Signals deprecated

Boost.Signals is no longer being actively maintained, so it has been deprecated. Do not use Boost.Signals for new development (use Boost.Signals2 instead). If you have existing Boost.Signals-based code, it will continue to work, but consider moving…
nyan-cat
  • 610
  • 5
  • 19
2
votes
1 answer

Binding class member functions for boost::signals2

I have used std::bind to create a lambda involving a class member function but boost::signals2 won't accept it. I have a class Cut which I would like to inform when there is a new Event to look at by calling void Cut::newEvent(Event& e). I created a…
paco_uk
  • 445
  • 1
  • 5
  • 15
2
votes
1 answer

boost::signals2 undefined-reference when linking libraries together

I would like to link two libraries to my program. The first one, defines an object (of class ProducerObject) which emits a signal. The second library defines two classes: a slave class which contains several instances of ProducerObject and a master…
Chris
  • 23
  • 4
2
votes
2 answers

Why does enable_shared_from_this lack direct access to the embedded weak_ptr?

I want to use boost signals2 with automatic connection management in a multithreaded application. My class inherits from enable_shared_from_this<> and i want to connect a member method from within another member method. The connection might be…
eel76
  • 97
  • 12
2
votes
1 answer

What is wrong with this boost::lambda::bind usage?

Is there something wrong in this code? I keep getting compilation errors. Basically I want to connect a void returning function to a signal which has a non void return type. Boost version: Release 1.46.1 #include #include…
Sak
  • 269
  • 1
  • 4
  • 13
2
votes
2 answers

How do I use boost::signals to implement the observer pattern?

I have an application consisting of many linked objects, each of which have parameters that they need in order to function. I am using the context pattern so that each object sets its own parameters according to a context object reference that is…
learnvst
  • 15,455
  • 16
  • 74
  • 121
2
votes
1 answer

Boost.Signals2 destruction safety

I have a Boost.Signals2 signal on object 1, and I connect to it on object 2. If object 2 is destructed the signal will not disconnect which can lead to bad things when its signaled. To resolve this I keep a scoped_connection on object 2. The problem…
Daniel
  • 30,896
  • 18
  • 85
  • 139
1
vote
1 answer

Can't add a non-copyable connection to boost::signals2::signal

I was implementing a wrapper that would allow me to perfectly forward my handler (in this case Widget object) into a callable that I can then use as a signal handler. I managed to do this by forwarding my handler as a tuple and therefore when the…
bielu000
  • 1,826
  • 3
  • 21
  • 45
1
vote
0 answers

Error adding slots using lambdas (Boost Signals2)

The code below prints worldworld to the console rather than hello world. I can fix this by changing sig.connect([&]() { slot(); }); to sig.connect(slot), but don't understand why. What's happening? #include #include…
user6429576
1
vote
1 answer

Boost signals2 and std::shared_ptr?

Is it possible to configure (at compile time) boost::signals2 to use std::shared_ptr instead of boost::shared_ptr, for e.g. in calls like boost::signals2::deconstruct? I am using boost 1.68
zrb
  • 851
  • 7
  • 16
1
vote
1 answer

Boost Signals2 pass Slot to member Function for Disconnecting

I have the following class which uses a simple boost::Signals2::Signal: class Button { using OnClick = signal; public: using OnClickSlotType = OnClick::slot_type; boost::signals2::connection add_handler(const OnClickSlotType&…
Kevin
  • 785
  • 2
  • 10
  • 32
1
vote
1 answer

Is it safe to use a boost::signals2::scoped_connection object as member of a class for automatic connection lifetime?

I wondered whether the following code is safe with respect to the fact that the signal might be triggered by a different thread: using IntSignal = boost::signals2::signal; class Foo { public: Foo(IntSignal& signal) :…
Daniel
  • 311
  • 3
  • 12