26 #ifndef __XRD_CL_PARALLELOPERATION_HH__
27 #define __XRD_CL_PARALLELOPERATION_HH__
71 template<
bool HasHndl>
96 template<
class Container>
99 static_assert( !HasHndl,
"Constructor is available only operation without handler");
102 auto begin = std::make_move_iterator( container.begin() );
103 auto end = std::make_move_iterator( container.end() );
104 std::copy( begin, end, std::back_inserter(
pipelines ) );
113 std::ostringstream oss;
115 for(
size_t i = 0; i <
pipelines.size(); i++ )
136 return std::move( *
this );
148 return std::move( *
this );
160 return std::move( *
this );
173 return std::move( *
this );
188 if( status.
IsOK() )
return false;
209 size_t nb =
cnt.fetch_sub( 1 );
211 if( status.
IsOK() )
return true;
213 if( nb == 1 )
return true;
237 size_t nb =
cnt.fetch_sub( 1 );
273 size_t nb =
cnt.fetch_sub( 1 );
275 if( status.
IsOK() )
return false;
320 if(
policy->Examine( st ) )
360 std::shared_ptr<Ctx> ctx =
361 std::make_shared<Ctx>( this->
handler.release(),
policy.release() );
365 for(
size_t i = 0; i <
pipelines.size(); ++i )
374 catch(
const std::exception& ex )
389 template<
class Container>
407 template<
typename ... Others>
408 inline void PipesToVec( std::vector<Pipeline> &v, Operation<false> &operation,
411 template<
typename ... Others>
412 inline void PipesToVec( std::vector<Pipeline> &v, Operation<true> &operation,
415 template<
typename ... Others>
416 inline void PipesToVec( std::vector<Pipeline> &v, Pipeline &pipeline,
422 template<
typename ... Others>
426 v.emplace_back( operation );
430 template<
typename ... Others>
434 v.emplace_back( operation );
438 template<
typename ... Others>
442 v.emplace_back( std::move( pipeline ) );
452 template<
typename ... Operations>
455 constexpr
size_t size =
sizeof...( operations );
456 std::vector<Pipeline> v;
Definition: XrdClOperations.hh:476
Definition: XrdClOperations.hh:166
std::unique_ptr< PipelineHandler > handler
Operation handler.
Definition: XrdClOperations.hh:288
Definition: XrdClParallelOperation.hh:73
std::vector< Pipeline > pipelines
Definition: XrdClParallelOperation.hh:382
ParallelOperation(ParallelOperation< from > &&obj)
Constructor: copy-move a ParallelOperation in different state.
Definition: XrdClParallelOperation.hh:82
ParallelOperation(Container &&container)
Definition: XrdClParallelOperation.hh:97
XRootDStatus RunImpl()
Definition: XrdClParallelOperation.hh:355
std::unique_ptr< PolicyExecutor > policy
Definition: XrdClParallelOperation.hh:383
std::string ToString()
Definition: XrdClParallelOperation.hh:111
ParallelOperation< HasHndl > Some(size_t threshold)
Definition: XrdClParallelOperation.hh:157
ParallelOperation< HasHndl > All()
Definition: XrdClParallelOperation.hh:133
ParallelOperation< HasHndl > Any()
Definition: XrdClParallelOperation.hh:145
ParallelOperation< HasHndl > AtLeast(size_t threshold)
Definition: XrdClParallelOperation.hh:170
Pipeline exception, wrapps an XRootDStatus.
Definition: XrdClOperationHandlers.hh:360
const char * what() const noexcept
inherited from std::exception
Definition: XrdClOperationHandlers.hh:391
const XRootDStatus & GetError() const
Definition: XrdClOperationHandlers.hh:399
Definition: XrdClOperations.hh:57
void HandleResponse(XRootDStatus *status, AnyObject *response)
Callback function.
Definition: XrdClOperations.hh:304
Request status.
Definition: XrdClXRootDResponses.hh:215
Definition: XrdClAnyObject.hh:26
ParallelOperation< false > Parallel(Container &container)
Factory function for creating parallel operation from a vector.
Definition: XrdClParallelOperation.hh:390
void PipesToVec(std::vector< Pipeline > &)
Helper function for converting parameter pack into a vector.
Definition: XrdClParallelOperation.hh:398
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
Definition: XrdClParallelOperation.hh:185
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:186
Definition: XrdClParallelOperation.hh:201
std::atomic< size_t > cnt
Definition: XrdClParallelOperation.hh:219
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:206
AnyPolicy(size_t size)
Definition: XrdClParallelOperation.hh:202
Definition: XrdClParallelOperation.hh:265
std::atomic< size_t > cnt
Definition: XrdClParallelOperation.hh:282
const size_t threshold
Definition: XrdClParallelOperation.hh:283
AtLeastPolicy(size_t size, size_t threshold)
Definition: XrdClParallelOperation.hh:266
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:270
Definition: XrdClParallelOperation.hh:293
void Handle(const XRootDStatus &st)
Definition: XrdClParallelOperation.hh:330
void Examine(const XRootDStatus &st)
Definition: XrdClParallelOperation.hh:318
~Ctx()
Destructor.
Definition: XrdClParallelOperation.hh:307
std::unique_ptr< PolicyExecutor > policy
Policy defining when the user handler should be called.
Definition: XrdClParallelOperation.hh:345
std::atomic< PipelineHandler * > handler
PipelineHandler of the ParallelOperation.
Definition: XrdClParallelOperation.hh:340
Ctx(PipelineHandler *handler, PolicyExecutor *policy)
Definition: XrdClParallelOperation.hh:299
Definition: XrdClParallelOperation.hh:229
SomePolicy(size_t size, size_t threshold)
Definition: XrdClParallelOperation.hh:230
std::atomic< size_t > cnt
Definition: XrdClParallelOperation.hh:252
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:234
const size_t threshold
Definition: XrdClParallelOperation.hh:254
std::atomic< size_t > succeeded
Definition: XrdClParallelOperation.hh:253
Definition: XrdClParallelOperation.hh:56
virtual ~PolicyExecutor()
Definition: XrdClParallelOperation.hh:57
virtual bool Examine(const XrdCl::XRootDStatus &status)=0
Definition: XrdClOperationHandlers.hh:648
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:120