CatapultServer  v0.5.0.1 (Elephant)
ParallelValidationPolicy.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ValidatorTypes.h"
23 #include "catapult/thread/Future.h"
24 
25 namespace catapult { namespace thread { class IoThreadPool; } }
26 
27 namespace catapult { namespace validators {
28 
31  public:
32  virtual ~ParallelValidationPolicy() = default;
33 
34  public:
37  const model::WeakEntityInfos& entityInfos,
38  const ValidationFunctions& validationFunctions) const = 0;
39 
42  const model::WeakEntityInfos& entityInfos,
43  const ValidationFunctions& validationFunctions) const = 0;
44  };
45 
47  std::shared_ptr<const ParallelValidationPolicy> CreateParallelValidationPolicy(const std::shared_ptr<thread::IoThreadPool>& pPool);
48 }}
FutureUtils.h
catapult::validators::ValidationFunction
std::function< ValidationResult(const model::WeakEntityInfo &)> ValidationFunction
A validation function.
Definition: ValidatorTypes.h:49
m_entityInfos
model::WeakEntityInfos m_entityInfos
Definition: ParallelValidationPolicy.cpp:140
m_ioContext
boost::asio::io_context & m_ioContext
Definition: ParallelValidationPolicy.cpp:186
CATAPULT_LOG
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
m_impl
TTraits m_impl
Definition: ParallelValidationPolicy.cpp:142
m_results
std::vector< ValidationResult > m_results
Definition: ParallelValidationPolicy.cpp:89
ParallelValidationPolicy.h
m_pPool
std::shared_ptr< const thread::IoThreadPool > m_pPool
Definition: ParallelValidationPolicy.cpp:185
catapult::validators::ValidationResult
ValidationResult
Enumeration of all possible validation results.
Definition: ValidationResult.h:51
catapult::thread::compose
auto compose(future< TSeed > &&startFuture, TCreateNextFuture createNextFuture)
Definition: FutureUtils.h:102
catapult::validators::ResultSeverity::Success
Validation result is success.
m_validationFunctions
ValidationFunctions m_validationFunctions
Definition: ParallelValidationPolicy.cpp:139
catapult::validators::ParallelValidationPolicy
A parallel validation policy that performs parallel validations on multiple threads.
Definition: ParallelValidationPolicy.h:30
ParallelFor.h
catapult::validators::ParallelValidationPolicy::validateShortCircuit
virtual thread::future< ValidationResult > validateShortCircuit(const model::WeakEntityInfos &entityInfos, const ValidationFunctions &validationFunctions) const =0
Validates all entityInfos using validationFunctions and short circuits on first failure.
catapult::validators::AggregateValidationResult
void AggregateValidationResult(std::atomic< ValidationResult > &aggregate, ValidationResult value)
Aggregates result into aggregate.
Definition: AggregateValidationResult.cpp:62
catapult::validators::ParallelValidationPolicy::~ParallelValidationPolicy
virtual ~ParallelValidationPolicy()=default
AggregateValidationResult.h
catapult::thread::future
Provides a way to access the result of an asynchronous operation.
Definition: Future.h:29
IsEntityShortCircuitAllowed
static constexpr bool IsEntityShortCircuitAllowed
Definition: ParallelValidationPolicy.cpp:39
IoThreadPool.h
m_pOwner
std::shared_ptr< const void > m_pOwner
Definition: ParallelValidationPolicy.cpp:138
catapult::model::WeakEntityInfo
WeakEntityInfoT< VerifiableEntity > WeakEntityInfo
Definition: WeakEntityInfo.h:128
catapult::validators::ParallelValidationPolicy::validateAll
virtual thread::future< std::vector< ValidationResult > > validateAll(const model::WeakEntityInfos &entityInfos, const ValidationFunctions &validationFunctions) const =0
Validates all entityInfos using validationFunctions and does NOT short circuit on failures.
ValidatorTypes.h
catapult::validators::ValidationResult::Success
Validation succeeded.
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::validators::IsValidationResultFailure
constexpr bool IsValidationResultFailure(ValidationResult result)
Returns a value indicating whether the validation result is a failure.
Definition: ValidationResult.h:95
Future.h
Logging.h
catapult::validators::ValidationFunctions
std::vector< ValidationFunction > ValidationFunctions
A vector of validation functions.
Definition: ValidatorTypes.h:52
catapult::validators::CreateParallelValidationPolicy
std::shared_ptr< const ParallelValidationPolicy > CreateParallelValidationPolicy(const std::shared_ptr< thread::IoThreadPool > &pPool)
Creates a parallel validation policy using pPool for parallelization.
Definition: ParallelValidationPolicy.cpp:190
m_aggregateResult
std::atomic< ValidationResult > m_aggregateResult
Definition: ParallelValidationPolicy.cpp:60
catapult::model::WeakEntityInfos
std::vector< WeakEntityInfo > WeakEntityInfos
A container of weak entity infos.
Definition: WeakEntityInfo.h:144
m_promise
thread::promise< typename TTraits::ResultType > m_promise
Definition: ParallelValidationPolicy.cpp:141
catapult::thread::ParallelFor
thread::future< bool > ParallelFor(boost::asio::io_context &ioContext, TItems &items, size_t numPartitions, TWorkCallback callback)
Definition: ParallelFor.h:118