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 1185 of file XrdClXRootDResponses.hh.

Constructor & Destructor Documentation

◆ ~ResponseHandler()

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

Definition at line 1188 of file XrdClXRootDResponses.hh.

1188{}

Member Function Documentation

◆ HandleResponse()

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

◆ 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 1199 of file XrdClXRootDResponses.hh.

1202 {
1203 delete hostList;
1204 HandleResponse( status, response );
1205 }
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)

References HandleResponse().

Referenced by XrdCl::AssignLastURLHandler::HandleResponseWithHosts(), XrdCl::AssignLBHandler::HandleResponseWithHosts(), XrdCl::LocalFileTask::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 760 of file XrdClXRootDResponses.cc.

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

References XrdCl::Status::code, HandleResponse(), 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 792 of file XrdClXRootDResponses.cc.

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

References XrdCl::Status::code, HandleResponse(), 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: