diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-08-13 15:01:07 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-08-13 15:02:38 -0400 |
commit | ddc3ec92b0e655a3da21ac2e85ec2e7ecb66c65b (patch) | |
tree | e446883baf2424095ce0ad1a936d6d26c3a5cb9c /src/ui_interface.h | |
parent | f87d0a9d75b366445f880041c56c725f8196364e (diff) | |
parent | fa5ce27385bc60cdf6d9a4eeb2d32c916c9e07eb (diff) |
Merge #13634: ui: Compile boost::signals2 only once
fa5ce27385 ui: Compile boost:signals2 only once (MarcoFalke)
Pull request description:
ui is one of the modules that poison other modules with `boost/signals2` headers. This moves the include to the cpp file and uses a forward declaration in the header.
Locally this speeds up the incremental build (building everything that uses the ui module) with gcc by ~5% for me. Gcc uses ~5% less memory.
Would be nice if someone could verify the numbers roughly.
I presume the improvements will be more pronounced if the other models would stop exposing the boost header as well.
Tree-SHA512: 078360eba330ddbca4268bd8552927eae242a239e18dfded25ec20be72650a68cd83af7ac160690249b943d33ae35d15df1313f1f60a0c28b9526853aa7d1e40
Diffstat (limited to 'src/ui_interface.h')
-rw-r--r-- | src/ui_interface.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/ui_interface.h b/src/ui_interface.h index a570573991..992c585b10 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -6,15 +6,18 @@ #ifndef BITCOIN_UI_INTERFACE_H #define BITCOIN_UI_INTERFACE_H +#include <functional> #include <memory> #include <stdint.h> #include <string> -#include <boost/signals2/last_value.hpp> -#include <boost/signals2/signal.hpp> - class CWallet; class CBlockIndex; +namespace boost { +namespace signals2 { +class connection; +} +} // namespace boost /** General change type (added, updated, removed). */ enum ChangeType @@ -72,43 +75,49 @@ public: MSG_ERROR = (ICON_ERROR | BTN_OK | MODAL) }; +#define ADD_SIGNALS_DECL_WRAPPER(signal_name, rtype, args...) \ + rtype signal_name(args); \ + using signal_name##Sig = rtype(args); \ + boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn); \ + void signal_name##_disconnect(std::function<signal_name##Sig> fn); + /** Show message box. */ - boost::signals2::signal<bool (const std::string& message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeMessageBox; + ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style); /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */ - boost::signals2::signal<bool (const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style), boost::signals2::last_value<bool> > ThreadSafeQuestion; + ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style); /** Progress message during initialization. */ - boost::signals2::signal<void (const std::string &message)> InitMessage; + ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message); /** Number of network connections changed. */ - boost::signals2::signal<void (int newNumConnections)> NotifyNumConnectionsChanged; + ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections); /** Network activity state changed. */ - boost::signals2::signal<void (bool networkActive)> NotifyNetworkActiveChanged; + ADD_SIGNALS_DECL_WRAPPER(NotifyNetworkActiveChanged, void, bool networkActive); /** * Status bar alerts changed. */ - boost::signals2::signal<void ()> NotifyAlertChanged; + ADD_SIGNALS_DECL_WRAPPER(NotifyAlertChanged, void, ); /** A wallet has been loaded. */ - boost::signals2::signal<void (std::shared_ptr<CWallet> wallet)> LoadWallet; + ADD_SIGNALS_DECL_WRAPPER(LoadWallet, void, std::shared_ptr<CWallet> wallet); /** * Show progress e.g. for verifychain. * resume_possible indicates shutting down now will result in the current progress action resuming upon restart. */ - boost::signals2::signal<void (const std::string &title, int nProgress, bool resume_possible)> ShowProgress; + ADD_SIGNALS_DECL_WRAPPER(ShowProgress, void, const std::string& title, int nProgress, bool resume_possible); /** New block has been accepted */ - boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyBlockTip; + ADD_SIGNALS_DECL_WRAPPER(NotifyBlockTip, void, bool, const CBlockIndex*); /** Best header has changed */ - boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyHeaderTip; + ADD_SIGNALS_DECL_WRAPPER(NotifyHeaderTip, void, bool, const CBlockIndex*); /** Banlist did change. */ - boost::signals2::signal<void (void)> BannedListChanged; + ADD_SIGNALS_DECL_WRAPPER(BannedListChanged, void, void); }; /** Show warning message **/ |