Skip to content

Commit 195df1e

Browse files
author
MacroFake
committed
Merge bitcoin/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
2 parents bc2eee7 + ca1ac1f commit 195df1e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/validationinterface.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
#include <unordered_map>
1717
#include <utility>
1818

19-
//! The MainSignalsInstance manages a list of shared_ptr<CValidationInterface>
20-
//! callbacks.
21-
//!
22-
//! A std::unordered_map is used to track what callbacks are currently
23-
//! registered, and a std::list is to used to store the callbacks that are
24-
//! currently registered as well as any callbacks that are just unregistered
25-
//! and about to be deleted when they are done executing.
26-
struct MainSignalsInstance {
19+
/**
20+
* MainSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
21+
*
22+
* A std::unordered_map is used to track what callbacks are currently
23+
* registered, and a std::list is used to store the callbacks that are
24+
* currently registered as well as any callbacks that are just unregistered
25+
* and about to be deleted when they are done executing.
26+
*/
27+
class MainSignalsImpl
28+
{
2729
private:
2830
Mutex m_mutex;
2931
//! List entries consist of a callback pointer and reference count. The
@@ -40,7 +42,7 @@ struct MainSignalsInstance {
4042
// our own queue here :(
4143
SingleThreadedSchedulerClient m_schedulerClient;
4244

43-
explicit MainSignalsInstance(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
45+
explicit MainSignalsImpl(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
4446

4547
void Register(std::shared_ptr<CValidationInterface> callbacks)
4648
{
@@ -92,7 +94,7 @@ static CMainSignals g_signals;
9294
void CMainSignals::RegisterBackgroundSignalScheduler(CScheduler& scheduler)
9395
{
9496
assert(!m_internals);
95-
m_internals = std::make_unique<MainSignalsInstance>(scheduler);
97+
m_internals = std::make_unique<MainSignalsImpl>(scheduler);
9698
}
9799

98100
void CMainSignals::UnregisterBackgroundSignalScheduler()

src/validationinterface.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ class BlockValidationState;
1717
class CBlock;
1818
class CBlockIndex;
1919
struct CBlockLocator;
20-
class CConnman;
2120
class CValidationInterface;
22-
class uint256;
2321
class CScheduler;
2422
enum class MemPoolRemovalReason;
2523

@@ -177,10 +175,10 @@ class CValidationInterface {
177175
friend class ValidationInterfaceTest;
178176
};
179177

180-
struct MainSignalsInstance;
178+
class MainSignalsImpl;
181179
class CMainSignals {
182180
private:
183-
std::unique_ptr<MainSignalsInstance> m_internals;
181+
std::unique_ptr<MainSignalsImpl> m_internals;
184182

185183
friend void ::RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface>);
186184
friend void ::UnregisterValidationInterface(CValidationInterface*);

0 commit comments

Comments
 (0)