XRootD
Loading...
Searching...
No Matches
XrdCl::ResponseHandler Class Reference

Handle an async response. More...

#include <XrdClXRootDResponses.hh>

+ Inheritance diagram for XrdCl::ResponseHandler:
+ Collaboration diagram for XrdCl::ResponseHandler:

Public Member Functions

virtual ~ResponseHandler ()
 
virtual void HandleResponse (XRootDStatus *status, AnyObject *response)
 
virtual void HandleResponseWithHosts (XRootDStatus *status, AnyObject *response, HostList *hostList)
 

Static Public Member Functions

static ResponseHandlerWrap (std::function< void(XRootDStatus &, AnyObject &)> func)
 
static ResponseHandlerWrap (std::function< void(XRootDStatus *, AnyObject *)> func)
 

Detailed Description

Handle an async response.

Definition at line 1126 of file XrdClXRootDResponses.hh.

Constructor & Destructor Documentation

◆ ~ResponseHandler()

virtual XrdCl::ResponseHandler::~ResponseHandler ( )
inlinevirtual

Definition at line 1129 of file XrdClXRootDResponses.hh.

1129{}

Member Function Documentation

◆ HandleResponse()

virtual void XrdCl::ResponseHandler::HandleResponse ( XRootDStatus * status,
AnyObject * response )
inlinevirtual

Called when a response to associated request arrives or an error occurs

Parameters
statusstatus of the request
responsean object associated with the response (request dependent)

Reimplemented in XrdCl::ChunkHandler, XrdCl::EcPgReadResponseHandler, XrdCl::FutureWrapper< Response >, XrdCl::FutureWrapper< void >, XrdCl::MetalinkReadHandler, XrdCl::PgReadSubstitutionHandler, XrdCl::PipelineHandler, XrdCl::SyncResponseHandler, XrdCl::TaskWrapper< Response, Return >, XrdCl::TaskWrapper< void, Return >, XrdCl::UnpackXAttr, XrdCl::UnpackXAttrStatus, XrdCl::ZipListHandler, XrdPosixFile, XrdPosixFileRH, and XrdSsiEvent.

Definition at line 1156 of file XrdClXRootDResponses.hh.

1158 {
1159 (void)status; (void)response;
1160 }

Referenced by XrdCl::EcHandler::Close(), XrdCl::HttpFilePlugIn::Close(), XrdCl::ZipArchive::CloseArchive(), XrdCl::HttpFileSystemPlugIn::DirList(), XrdCl::EcPgReadResponseHandler::HandleResponse(), XrdCl::MetalinkReadHandler::HandleResponse(), XrdCl::PgReadSubstitutionHandler::HandleResponse(), XrdCl::UnpackXAttr::HandleResponse(), XrdCl::UnpackXAttrStatus::HandleResponse(), XrdCl::ZipListHandler::HandleResponse(), HandleResponseWithHosts(), XrdCl::HttpFileSystemPlugIn::MkDir(), XrdCl::HttpFileSystemPlugIn::Mv(), XrdCl::HttpFilePlugIn::Open(), XrdEc::Reader::Open(), XrdCl::ZipArchive::OpenArchive(), XrdCl::FileStateHandler::PgWrite(), XrdCl::HttpFilePlugIn::Read(), XrdCl::HttpFileSystemPlugIn::Rm(), XrdCl::HttpFileSystemPlugIn::RmDir(), XrdEc::ResponseJob::Run(), XrdCl::HttpFilePlugIn::Stat(), XrdCl::HttpFileSystemPlugIn::Stat(), XrdCl::HttpFilePlugIn::VectorRead(), XrdEc::Reader::VectorRead(), and XrdCl::HttpFilePlugIn::Write().

+ Here is the caller graph for this function:

◆ HandleResponseWithHosts()

virtual void XrdCl::ResponseHandler::HandleResponseWithHosts ( XRootDStatus * status,
AnyObject * response,
HostList * hostList )
inlinevirtual

Called when a response to associated request arrives or an error occurs

Parameters
statusstatus of the request
responsean object associated with the response (request dependent)
hostListlist of hosts the request was redirected to

Reimplemented in XrdCl::AssignLastURLHandler, XrdCl::AssignLBHandler, XrdCl::ExOpenFuncWrapper, XrdCl::FunctionWrapper< Response >, XrdCl::FunctionWrapper< void >, XrdCl::MetalinkOpenHandler, XrdCl::NullResponseHandler, XrdCl::PipelineHandler, and XrdCl::RawWrapper.

Definition at line 1140 of file XrdClXRootDResponses.hh.

1143 {
1144 delete hostList;
1145 HandleResponse( status, response );
1146 }
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)

References HandleResponse().

Referenced by XrdCl::AssignLastURLHandler::HandleResponseWithHosts(), XrdCl::AssignLBHandler::HandleResponseWithHosts(), XrdCl::MetalinkOpenHandler::HandleResponseWithHosts(), XrdCl::RawWrapper::HandleResponseWithHosts(), XrdCl::LocalFileTask::Run(), XrdCl::ResponseJob::Run(), and XrdCl::FileStateHandler::Stat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Wrap() [1/2]

ResponseHandler * XrdCl::ResponseHandler::Wrap ( std::function< void(XRootDStatus &, AnyObject &)> func)
static

Factory function for generating handler objects from lambdas

Parameters
func: the callback, must not throw
Returns
: ResponseHandler wrapper with the user callback

Definition at line 754 of file XrdClXRootDResponses.cc.

755 {
756 struct FuncHandler : public ResponseHandler
757 {
758 FuncHandler( std::function<void(XRootDStatus&, AnyObject&)> func ) : func( std::move( func ) )
759 {
760 }
761
762 void HandleResponse( XRootDStatus *status, AnyObject *response )
763 {
764 // make sure the arguments will be released
765 std::unique_ptr<XRootDStatus> stptr( status );
766 std::unique_ptr<AnyObject> rspptr( response );
767 // if there is no response provide a null reference placeholder
768 static AnyObject nullref;
769 if( response == nullptr )
770 response = &nullref;
771 // call the user completion handler
772 func( *status, *response );
773 // check if this is a final respons
774 bool finalrsp = !( status->IsOK() && status->code == suContinue );
775 // deallocate the wrapper if final
776 if( finalrsp )
777 delete this;
778 }
779
780 std::function<void(XRootDStatus&, AnyObject&)> func;
781 };
782
783 return new FuncHandler( func );
784 }

References XrdCl::Status::code, XrdCl::Status::IsOK(), and XrdCl::suContinue.

Referenced by XrdCl::EcHandler::Close(), and XrdCl::FileStateHandler::PgWrite().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Wrap() [2/2]

ResponseHandler * XrdCl::ResponseHandler::Wrap ( std::function< void(XRootDStatus *, AnyObject *)> func)
static

Factory function for generating handler objects from lambdas

Parameters
func: the callback, must not throw
Returns
: ResponseHandler wrapper with the user callback

Definition at line 786 of file XrdClXRootDResponses.cc.

787 {
788 struct FuncHandler : public ResponseHandler
789 {
790 FuncHandler( std::function<void(XRootDStatus*, AnyObject*)> func ) : func( std::move( func ) )
791 {
792 }
793
794 void HandleResponse( XRootDStatus *status, AnyObject *response )
795 {
796 // check if this is a final respons
797 bool finalrsp = !( status->IsOK() && status->code == suContinue );
798 // call the user completion handler
799 func( status, response );
800 // deallocate the wrapper if final
801 if( finalrsp )
802 delete this;
803 }
804
805 std::function<void(XRootDStatus*, AnyObject*)> func;
806 };
807
808 return new FuncHandler( func );
809 }

References XrdCl::Status::code, XrdCl::Status::IsOK(), and XrdCl::suContinue.

+ Here is the call graph for this function:

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