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.cpp | |
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.cpp')
-rw-r--r-- | src/ui_interface.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/ui_interface.cpp b/src/ui_interface.cpp index 336d193b4e..22b4768059 100644 --- a/src/ui_interface.cpp +++ b/src/ui_interface.cpp @@ -5,8 +5,60 @@ #include <ui_interface.h> #include <util.h> +#include <boost/signals2/last_value.hpp> +#include <boost/signals2/signal.hpp> + CClientUIInterface uiInterface; +struct UISignals { + boost::signals2::signal<CClientUIInterface::ThreadSafeMessageBoxSig, boost::signals2::last_value<bool>> ThreadSafeMessageBox; + boost::signals2::signal<CClientUIInterface::ThreadSafeQuestionSig, boost::signals2::last_value<bool>> ThreadSafeQuestion; + boost::signals2::signal<CClientUIInterface::InitMessageSig> InitMessage; + boost::signals2::signal<CClientUIInterface::NotifyNumConnectionsChangedSig> NotifyNumConnectionsChanged; + boost::signals2::signal<CClientUIInterface::NotifyNetworkActiveChangedSig> NotifyNetworkActiveChanged; + boost::signals2::signal<CClientUIInterface::NotifyAlertChangedSig> NotifyAlertChanged; + boost::signals2::signal<CClientUIInterface::LoadWalletSig> LoadWallet; + boost::signals2::signal<CClientUIInterface::ShowProgressSig> ShowProgress; + boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip; + boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip; + boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged; +} g_ui_signals; + +#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \ + boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \ + { \ + return g_ui_signals.signal_name.connect(fn); \ + } \ + void CClientUIInterface::signal_name##_disconnect(std::function<signal_name##Sig> fn) \ + { \ + return g_ui_signals.signal_name.disconnect(&fn); \ + } + +ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox); +ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion); +ADD_SIGNALS_IMPL_WRAPPER(InitMessage); +ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged); +ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged); +ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged); +ADD_SIGNALS_IMPL_WRAPPER(LoadWallet); +ADD_SIGNALS_IMPL_WRAPPER(ShowProgress); +ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip); +ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip); +ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged); + +bool CClientUIInterface::ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); } +bool CClientUIInterface::ThreadSafeQuestion(const std::string& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); } +void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); } +void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); } +void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); } +void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); } +void CClientUIInterface::LoadWallet(std::shared_ptr<CWallet> wallet) { return g_ui_signals.LoadWallet(wallet); } +void CClientUIInterface::ShowProgress(const std::string& title, int nProgress, bool resume_possible) { return g_ui_signals.ShowProgress(title, nProgress, resume_possible); } +void CClientUIInterface::NotifyBlockTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyBlockTip(b, i); } +void CClientUIInterface::NotifyHeaderTip(bool b, const CBlockIndex* i) { return g_ui_signals.NotifyHeaderTip(b, i); } +void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListChanged(); } + + bool InitError(const std::string& str) { uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR); |