Changeset View
Changeset View
Standalone View
Standalone View
src/validationinterface.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_VALIDATIONINTERFACE_H | #ifndef BITCOIN_VALIDATIONINTERFACE_H | ||||
#define BITCOIN_VALIDATIONINTERFACE_H | #define BITCOIN_VALIDATIONINTERFACE_H | ||||
#include "primitives/transaction.h" // CTransaction(Ref) | #include "primitives/transaction.h" // CTransaction(Ref) | ||||
#include "sync.h" | |||||
#include <functional> | #include <functional> | ||||
#include <memory> | #include <memory> | ||||
class CBlock; | class CBlock; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
struct CBlockLocator; | struct CBlockLocator; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
Show All 18 Lines | |||||
* | * | ||||
* Be very careful blocking on func to be called if any locks are held - | * Be very careful blocking on func to be called if any locks are held - | ||||
* validation interface clients may not be able to make progress as they often | * validation interface clients may not be able to make progress as they often | ||||
* wait for things like cs_main, so blocking until func is called with cs_main | * wait for things like cs_main, so blocking until func is called with cs_main | ||||
* will result in a deadlock (that DEBUG_LOCKORDER will miss). | * will result in a deadlock (that DEBUG_LOCKORDER will miss). | ||||
*/ | */ | ||||
void CallFunctionInValidationInterfaceQueue(std::function<void()> func); | void CallFunctionInValidationInterfaceQueue(std::function<void()> func); | ||||
/** | |||||
* This is a synonym for the following, which asserts certain locks are not | |||||
* held: | |||||
* std::promise<void> promise; | |||||
* CallFunctionInValidationInterfaceQueue([&promise] { | |||||
* promise.set_value(); | |||||
* }); | |||||
* promise.get_future().wait(); | |||||
*/ | |||||
void SyncWithValidationInterfaceQueue() LOCKS_EXCLUDED(cs_main); | |||||
class CValidationInterface { | class CValidationInterface { | ||||
protected: | protected: | ||||
/** | /** | ||||
* Protected destructor so that instances can only be deleted by derived | * Protected destructor so that instances can only be deleted by derived | ||||
* classes. If that restriction is no longer desired, this should be made | * classes. If that restriction is no longer desired, this should be made | ||||
* public and virtual. | * public and virtual. | ||||
*/ | */ | ||||
~CValidationInterface() = default; | ~CValidationInterface() = default; | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |