XRootD
XrdCl::FutureWrapper< Response > Class Template Reference

#include <XrdClOperationHandlers.hh>

+ Inheritance diagram for XrdCl::FutureWrapper< Response >:
+ Collaboration diagram for XrdCl::FutureWrapper< Response >:

Public Member Functions

 FutureWrapper (std::future< Response > &ftr)
 
void HandleResponse (XRootDStatus *status, AnyObject *response)
 Callback method. More...
 
- Public Member Functions inherited from XrdCl::FutureWrapperBase< Response >
 FutureWrapperBase (std::future< Response > &ftr)
 
virtual ~FutureWrapperBase ()
 Destructor. More...
 
- Public Member Functions inherited from XrdCl::ResponseHandler
virtual ~ResponseHandler ()
 
virtual void HandleResponseWithHosts (XRootDStatus *status, AnyObject *response, HostList *hostList)
 

Additional Inherited Members

- Static Public Member Functions inherited from XrdCl::ResponseHandler
static ResponseHandlerWrap (std::function< void(XRootDStatus &, AnyObject &)> func)
 
static ResponseHandlerWrap (std::function< void(XRootDStatus *, AnyObject *)> func)
 
- Protected Member Functions inherited from XrdCl::FutureWrapperBase< Response >
void SetException (const XRootDStatus &err)
 
- Protected Attributes inherited from XrdCl::FutureWrapperBase< Response >
bool fulfilled
 
std::promise< Response > prms
 promise that corresponds to the future More...
 

Detailed Description

template<typename Response>
class XrdCl::FutureWrapper< Response >

A wrapper handler for a std::promise / std::future.

  • Response : response type

Definition at line 502 of file XrdClOperationHandlers.hh.

Constructor & Destructor Documentation

◆ FutureWrapper()

template<typename Response >
XrdCl::FutureWrapper< Response >::FutureWrapper ( std::future< Response > &  ftr)
inline

Constructor,

See also
FutureWrapperBase
Parameters
ftr: the future to be linked with this handler

Definition at line 511 of file XrdClOperationHandlers.hh.

511  : FutureWrapperBase<Response>( ftr )
512  {
513  }

Member Function Documentation

◆ HandleResponse()

template<typename Response >
void XrdCl::FutureWrapper< Response >::HandleResponse ( XRootDStatus status,
AnyObject response 
)
inlinevirtual

Callback method.

Reimplemented from XrdCl::ResponseHandler.

Definition at line 518 of file XrdClOperationHandlers.hh.

519  {
520  std::unique_ptr<XRootDStatus> delst( status );
521  std::unique_ptr<AnyObject> delrsp( response );
522  if( status->IsOK() ) {
523  if(Response *resp = GetResponse<Response>( response )) {
524  this->prms.set_value( std::move( *resp ) );
525  this->fulfilled = true;
526  } else {
527  this->SetException( XRootDStatus( stError, errInternal ) );
528  }
529  } else {
530  this->SetException( *status );
531  }
532  }
void SetException(const XRootDStatus &err)
std::promise< Response > prms
promise that corresponds to the future
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:56

References XrdCl::errInternal, XrdCl::FutureWrapperBase< Response >::fulfilled, XrdCl::Status::IsOK(), XrdCl::FutureWrapperBase< Response >::prms, XrdCl::FutureWrapperBase< Response >::SetException(), and XrdCl::stError.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: