Skip to content

Commit f557dc4

Browse files
MacroFakeknst
authored andcommitted
Merge bitcoin#25067: validationinterface: make MainSignalsInstance() a class, drop unused forward declarations
ca1ac1f scripted-diff: Rename MainSignalsInstance() class to MainSignalsImpl() (Jon Atack) 2aaec23 refactor: remove unused forward declarations in validationinterface.h (Jon Atack) 23854f8 refactor: make MainSignalsInstance() a class (Jon Atack) Pull request description: Make MainSignalsInstance a class, rename it to MainSignalsImpl, use Doxygen documentation for it, and remove no longer used forward declarations in src/validationinterface.h. ---- MainSignalsInstance was created in 3a19fed and originally was a collection of boost::signals methods moved to validationinterface.cpp, in order to no longer need to include boost/signals in validationinterface.h. MainSignalsInstance then evolved in d6815a2 to become class-like: - [C.8: Use class rather than struct if any member is non-public](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-class) - [C.2: Use class if the class has an invariant; use struct if the data members can vary independently](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently) - A class has the advantage of default private access, as opposed to public for a struct. ACKs for top commit: furszy: Code ACK ca1ac1f promag: Code review ACK ca1ac1f. danielabrozzoni: Code review ACK ca1ac1f Tree-SHA512: 25f85e2b582fe8c269e6cf384a4aa29350b97ea6477edf3c63591e4f68a97364f7fb2fc4ad2764f61ff86b27353e31d2f12eed7a23368a247e4cf271c7e133ea
1 parent 764893d commit f557dc4

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/masternode/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <threadsafety.h>
1212
#include <validationinterface.h>
1313

14+
class CConnman;
1415
class CDeterministicMNManager;
1516

1617
struct CActiveMasternodeInfo {

src/validationinterface.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919

2020
std::string RemovalReasonToString(const MemPoolRemovalReason& r) noexcept;
2121

22-
//! The MainSignalsInstance manages a list of shared_ptr<CValidationInterface>
23-
//! callbacks.
24-
//!
25-
//! A std::unordered_map is used to track what callbacks are currently
26-
//! registered, and a std::list is to used to store the callbacks that are
27-
//! currently registered as well as any callbacks that are just unregistered
28-
//! and about to be deleted when they are done executing.
29-
struct MainSignalsInstance {
22+
/**
23+
* MainSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
24+
*
25+
* A std::unordered_map is used to track what callbacks are currently
26+
* registered, and a std::list is used to store the callbacks that are
27+
* currently registered as well as any callbacks that are just unregistered
28+
* and about to be deleted when they are done executing.
29+
*/
30+
class MainSignalsImpl
31+
{
3032
private:
3133
Mutex m_mutex;
3234
//! List entries consist of a callback pointer and reference count. The
@@ -43,7 +45,7 @@ struct MainSignalsInstance {
4345
// our own queue here :(
4446
SingleThreadedSchedulerClient m_schedulerClient;
4547

46-
explicit MainSignalsInstance(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
48+
explicit MainSignalsImpl(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
4749

4850
void Register(std::shared_ptr<CValidationInterface> callbacks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
4951
{
@@ -95,7 +97,7 @@ static CMainSignals g_signals;
9597
void CMainSignals::RegisterBackgroundSignalScheduler(CScheduler& scheduler)
9698
{
9799
assert(!m_internals);
98-
m_internals = std::make_unique<MainSignalsInstance>(scheduler);
100+
m_internals = std::make_unique<MainSignalsImpl>(scheduler);
99101
}
100102

101103
void CMainSignals::UnregisterBackgroundSignalScheduler()

src/validationinterface.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ class BlockValidationState;
1717
class CBlock;
1818
class CBlockIndex;
1919
struct CBlockLocator;
20-
class CConnman;
2120
class CValidationInterface;
2221
class CGovernanceVote;
2322
class CDeterministicMNList;
2423
class CDeterministicMNListDiff;
25-
class uint256;
2624
class CScheduler;
2725
enum class MemPoolRemovalReason;
2826
namespace chainlock {
@@ -204,10 +202,10 @@ class CValidationInterface {
204202
friend class ValidationInterfaceTest;
205203
};
206204

207-
struct MainSignalsInstance;
205+
class MainSignalsImpl;
208206
class CMainSignals {
209207
private:
210-
std::unique_ptr<MainSignalsInstance> m_internals;
208+
std::unique_ptr<MainSignalsImpl> m_internals;
211209

212210
friend void ::RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface>);
213211
friend void ::UnregisterValidationInterface(CValidationInterface*);

0 commit comments

Comments
 (0)