mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
Merge bitcoin/bitcoin#25067: validationinterface: make MainSignalsInstance() a class, drop unused forward declarations
ca1ac1f0e0
scripted-diff: Rename MainSignalsInstance() class to MainSignalsImpl() (Jon Atack)2aaec2352d
refactor: remove unused forward declarations in validationinterface.h (Jon Atack)23854f8402
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 in3a19fed9db
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 ind6815a2313
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 ACKca1ac1f
promag: Code review ACKca1ac1f0e0
. danielabrozzoni: Code review ACKca1ac1f0e0
Tree-SHA512: 25f85e2b582fe8c269e6cf384a4aa29350b97ea6477edf3c63591e4f68a97364f7fb2fc4ad2764f61ff86b27353e31d2f12eed7a23368a247e4cf271c7e133ea
This commit is contained in:
commit
195df1eb88
2 changed files with 14 additions and 14 deletions
|
@ -16,14 +16,16 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
//! The MainSignalsInstance manages a list of shared_ptr<CValidationInterface>
|
/**
|
||||||
//! callbacks.
|
* MainSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.
|
||||||
//!
|
*
|
||||||
//! A std::unordered_map is used to track what callbacks are currently
|
* A std::unordered_map is used to track what callbacks are currently
|
||||||
//! registered, and a std::list is to used to store the callbacks that are
|
* registered, and a std::list is used to store the callbacks that are
|
||||||
//! currently registered as well as any callbacks that are just unregistered
|
* currently registered as well as any callbacks that are just unregistered
|
||||||
//! and about to be deleted when they are done executing.
|
* and about to be deleted when they are done executing.
|
||||||
struct MainSignalsInstance {
|
*/
|
||||||
|
class MainSignalsImpl
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
Mutex m_mutex;
|
Mutex m_mutex;
|
||||||
//! List entries consist of a callback pointer and reference count. The
|
//! List entries consist of a callback pointer and reference count. The
|
||||||
|
@ -40,7 +42,7 @@ public:
|
||||||
// our own queue here :(
|
// our own queue here :(
|
||||||
SingleThreadedSchedulerClient m_schedulerClient;
|
SingleThreadedSchedulerClient m_schedulerClient;
|
||||||
|
|
||||||
explicit MainSignalsInstance(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
|
explicit MainSignalsImpl(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
|
||||||
|
|
||||||
void Register(std::shared_ptr<CValidationInterface> callbacks)
|
void Register(std::shared_ptr<CValidationInterface> callbacks)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +94,7 @@ static CMainSignals g_signals;
|
||||||
void CMainSignals::RegisterBackgroundSignalScheduler(CScheduler& scheduler)
|
void CMainSignals::RegisterBackgroundSignalScheduler(CScheduler& scheduler)
|
||||||
{
|
{
|
||||||
assert(!m_internals);
|
assert(!m_internals);
|
||||||
m_internals = std::make_unique<MainSignalsInstance>(scheduler);
|
m_internals = std::make_unique<MainSignalsImpl>(scheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainSignals::UnregisterBackgroundSignalScheduler()
|
void CMainSignals::UnregisterBackgroundSignalScheduler()
|
||||||
|
|
|
@ -17,9 +17,7 @@ class BlockValidationState;
|
||||||
class CBlock;
|
class CBlock;
|
||||||
class CBlockIndex;
|
class CBlockIndex;
|
||||||
struct CBlockLocator;
|
struct CBlockLocator;
|
||||||
class CConnman;
|
|
||||||
class CValidationInterface;
|
class CValidationInterface;
|
||||||
class uint256;
|
|
||||||
class CScheduler;
|
class CScheduler;
|
||||||
enum class MemPoolRemovalReason;
|
enum class MemPoolRemovalReason;
|
||||||
|
|
||||||
|
@ -177,10 +175,10 @@ protected:
|
||||||
friend class ValidationInterfaceTest;
|
friend class ValidationInterfaceTest;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MainSignalsInstance;
|
class MainSignalsImpl;
|
||||||
class CMainSignals {
|
class CMainSignals {
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<MainSignalsInstance> m_internals;
|
std::unique_ptr<MainSignalsImpl> m_internals;
|
||||||
|
|
||||||
friend void ::RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface>);
|
friend void ::RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface>);
|
||||||
friend void ::UnregisterValidationInterface(CValidationInterface*);
|
friend void ::UnregisterValidationInterface(CValidationInterface*);
|
||||||
|
|
Loading…
Add table
Reference in a new issue