cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.3k stars 940 forks source link

Replace boost::signals2 with C++11 implementation #619

Closed richardeakin closed 9 years ago

richardeakin commented 9 years ago

boost::signals2 is probably our largest dependancy on boost (other than filesystem and asio, which are both proposed for standardization), and it is also quite beefy in the realm of signals / slots implementations. Swapping it out is a breaking change, although only minor, in that method and class names will slightly change (ex. ci::signals::signal -> ci::signals::Signal).

Right now the favorite replacement candidate is a modified version of SimpleSignal, modifed in the sense that we still need to make up for a couple features. Specifically it doesn't support connections or scoped connections, and I'm not sure if its 'collector' notion equates to boost::signal2's 'combiner' notion. I have been using a modified version of SimpleSignal in private for some months now, and plan to implement these features before we make the switch.

Important: boost::signals2 is thread safe, SimpleSignal is not. This is not a problem for any of cinder's internal usage of signals, and for the most part signals are used from UI threads so it isn't a problem there either. However, if it is a problem for someone else, first please reconsider your design :), then let's discuss if this is actually a requirement for a ci::Signal implementation. Most likely, we would recommend that you keep using boost::signals2 directly, but we do want to know of any use cases that users could have and we don't know about.

Related to #611 Depends on #618 being accepted.

notlion commented 9 years ago

I'm already using SimpleSignal since it's included with the ECS library entityx, so switching to that specifically sounds nice to me. I don't need the thread safety and such that boost::signals2 provides.

The choice to use the more minimal / performant implementation of a feature seems like a good one, since we can always upgrade to something with more features for specific use cases.

The lack of connections seems to be the most glaring omission from SimpleSignal. That's the only thing I would miss. I've personally never used scoped connections.

meshula commented 9 years ago

I like to refer to libcaf for this sort of thing, but I'm after cross-thread and cross-process stuff. https://github.com/actor-framework/actor-framework

entityx is cool, but I didn't realize that SimpleSignal isn't thread safe.

richardeakin commented 9 years ago

Fixed in app_refactor branch, #710