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;
463 #endif // __XRD_CL_OPERATIONS_HH__ void PipesToVec(std::vector< Pipeline > &)
Helper function for converting parameter pack into a vector.
Definition: XrdClParallelOperation.hh:398
virtual bool Examine(const XrdCl::XRootDStatus &status)=0
std::atomic< size_t > succeeded
Definition: XrdClParallelOperation.hh:253
SomePolicy(size_t size, size_t threshold)
Definition: XrdClParallelOperation.hh:230
Definition: XrdClParallelOperation.hh:184
AtLeastPolicy(size_t size, size_t threshold)
Definition: XrdClParallelOperation.hh:266
std::string ToString()
Definition: XrdClParallelOperation.hh:111
ParallelOperation< HasHndl > All()
Definition: XrdClParallelOperation.hh:133
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:120
ParallelOperation< HasHndl > Any()
Definition: XrdClParallelOperation.hh:145
const size_t threshold
Definition: XrdClParallelOperation.hh:254
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:206
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:270
Definition: XrdClParallelOperation.hh:264
Definition: XrdClOperationHandlers.hh:647
Definition: XrdClParallelOperation.hh:228
std::atomic< size_t > cnt
Definition: XrdClParallelOperation.hh:219
void Handle(const XRootDStatus &st)
Definition: XrdClParallelOperation.hh:330
Pipeline exception, wrapps an XRootDStatus.
Definition: XrdClOperationHandlers.hh:359
std::unique_ptr< PolicyExecutor > policy
Policy defining when the user handler should be called.
Definition: XrdClParallelOperation.hh:345
ParallelOperation(ParallelOperation< from > &&obj)
Constructor: copy-move a ParallelOperation in different state.
Definition: XrdClParallelOperation.hh:82
AnyPolicy(size_t size)
Definition: XrdClParallelOperation.hh:202
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:186
std::atomic< size_t > cnt
Definition: XrdClParallelOperation.hh:282
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
Request status.
Definition: XrdClXRootDResponses.hh:214
Definition: XrdClAnyObject.hh:25
Definition: XrdClOperations.hh:42
ParallelOperation< HasHndl > Some(size_t threshold)
Definition: XrdClParallelOperation.hh:157
Ctx(PipelineHandler *handler, PolicyExecutor *policy)
Definition: XrdClParallelOperation.hh:299
const XRootDStatus & GetError() const
Definition: XrdClOperationHandlers.hh:399
bool Examine(const XrdCl::XRootDStatus &status)
Definition: XrdClParallelOperation.hh:234
std::atomic< PipelineHandler * > handler
PipelineHandler of the ParallelOperation.
Definition: XrdClParallelOperation.hh:340
Definition: XrdClOperations.hh:56
ParallelOperation< false > Parallel(Container &container)
Factory function for creating parallel operation from a vector.
Definition: XrdClParallelOperation.hh:390
std::vector< Pipeline > pipelines
Definition: XrdClParallelOperation.hh:382
ParallelOperation(Container &&container)
Definition: XrdClParallelOperation.hh:97
virtual ~PolicyExecutor()
Definition: XrdClParallelOperation.hh:57
void HandleResponse(XRootDStatus *status, AnyObject *response)
Callback function.
~Ctx()
Destructor.
Definition: XrdClParallelOperation.hh:307
ParallelOperation< HasHndl > AtLeast(size_t threshold)
Definition: XrdClParallelOperation.hh:170
XRootDStatus RunImpl()
Definition: XrdClParallelOperation.hh:355
Definition: XrdClParallelOperation.hh:200
Definition: XrdClParallelOperation.hh:55
std::atomic< size_t > cnt
Definition: XrdClParallelOperation.hh:252
void Examine(const XRootDStatus &st)
Definition: XrdClParallelOperation.hh:318
Definition: XrdClOperations.hh:303
Definition: XrdClParallelOperation.hh:72
std::unique_ptr< PolicyExecutor > policy
Definition: XrdClParallelOperation.hh:383
Definition: XrdClParallelOperation.hh:292
std::unique_ptr< PipelineHandler > handler
Operation handler.
Definition: XrdClOperations.hh:288
const size_t threshold
Definition: XrdClParallelOperation.hh:283
Definition: XrdClOperations.hh:475