Boost Synapse

Questions and Answers

Q: How does Boost Synapse differ from Boost Signals 2, which is also "non-intrusive"?

A: The main design difference is that in Boost Signals 2 emitting a signal requires a signal object. This is significant because in general it is not trivial to associate a Boost Signals 2 signal object with 3rd-party objects. When using Boost Synapse such association is not necessary because the 3rd-party object itself can be passed to emit.

Q: What is the design rationale for ignoring the value(s) returned by the connected functions?

A: A typical use case for Boost Synapse is when the caller of emit doesn't care if there are 0, 1 or many connected functions. Allowing return values makes the zero/many case quite tricky to deal with. On the other hand, passing a reference or a (shared) pointer to emit to return/accumulate values from any number of connected functions (if needed) is simpler and fits that case nicely.

Q: Is there a way to stop the emit loop before all connected functions have been called?

A: No, except by throwing an exception.

Q: I am concerned about code size, does Boost Synapse use a lot of templates?

A: Yes, there are templates instantiated for each signal type. This is done so that the dispatch by signal type occurs at compile-time, leaving only emitter dispatch at run-time. However, static types are erased as soon as possible, so template bloat is kept to a minimum.

Q: What are the dependencies of Boost Synapse?

A: See Building.

Q: I do not need thread-safety, is there a way to configure Boost Synapse to eliminate thread safety overhead?

A: Most data structures in Boost Synapse are not thread-safe, instead they are thread-local. The overhead of using the library across multiple threads is contained only in thread_local_queue.cpp, which is an optional component. See Building.

See also: Boost Synapse