WPILibC++ 2024.3.2
wpi::uv::Request Class Reference

Request. More...

#include <wpinet/uv/Request.h>

Inheritance diagram for wpi::uv::Request:
wpi::uv::RequestImpl< ConnectReq, uv_connect_t > wpi::uv::RequestImpl< GetAddrInfoReq, uv_getaddrinfo_t > wpi::uv::RequestImpl< GetNameInfoReq, uv_getnameinfo_t > wpi::uv::RequestImpl< ShutdownReq, uv_shutdown_t > wpi::uv::RequestImpl< UdpSendReq, uv_udp_send_t > wpi::uv::RequestImpl< WorkReq, uv_work_t > wpi::uv::RequestImpl< WriteReq, uv_write_t > wpi::uv::RequestImpl< T, U >

Public Types

using Type = uv_req_type
 

Public Member Functions

 Request (const Request &)=delete
 
 Request (Request &&)=delete
 
Requestoperator= (const Request &)=delete
 
Requestoperator= (Request &&)=delete
 
virtual ~Request () noexcept=default
 
Type GetType () const noexcept
 Get the type of the request. More...
 
const char * GetTypeName () const noexcept
 Get the name of the type of the request. More...
 
bool Cancel ()
 Cancel a pending request. More...
 
size_t RawSize () const noexcept
 Return the size of the underlying request type. More...
 
uv_req_tGetRawReq () noexcept
 Get the underlying request data structure. More...
 
const uv_req_tGetRawReq () const noexcept
 Get the underlying request data structure. More...
 
virtual void Keep () noexcept
 Keep this request in memory even if no outside shared_ptr references remain. More...
 
virtual std::shared_ptr< RequestRelease () noexcept
 No longer force holding this request in memory. More...
 
void ReportError (int err)
 Report an error. More...
 

Public Attributes

std::function< void(Error)> error
 Error callback. More...
 

Protected Member Functions

 Request (uv_req_t *uv_req)
 Constructor. More...
 

Detailed Description

Request.

Requests are not moveable or copyable. This class provides shared_ptr ownership and shared_from_this.

Member Typedef Documentation

◆ Type

Constructor & Destructor Documentation

◆ Request() [1/3]

wpi::uv::Request::Request ( const Request )
delete

◆ Request() [2/3]

wpi::uv::Request::Request ( Request &&  )
delete

◆ ~Request()

virtual wpi::uv::Request::~Request ( )
virtualdefaultnoexcept

◆ Request() [3/3]

wpi::uv::Request::Request ( uv_req_t uv_req)
inlineexplicitprotected

Constructor.

Member Function Documentation

◆ Cancel()

bool wpi::uv::Request::Cancel ( )
inline

Cancel a pending request.

This method fails if the request is executing or has finished executing. It can emit an error signal in case of errors.

Returns
True in case of success, false otherwise.

◆ GetRawReq() [1/2]

const uv_req_t * wpi::uv::Request::GetRawReq ( ) const
inlinenoexcept

Get the underlying request data structure.

Returns
The underlying request data structure.

◆ GetRawReq() [2/2]

uv_req_t * wpi::uv::Request::GetRawReq ( )
inlinenoexcept

Get the underlying request data structure.

Returns
The underlying request data structure.

◆ GetType()

Type wpi::uv::Request::GetType ( ) const
inlinenoexcept

Get the type of the request.

A base request offers no functionality to promote it to the actual request type. By means of this function, the type of the underlying request as specified by Type is made available.

Returns
The actual type of the request.

◆ GetTypeName()

const char * wpi::uv::Request::GetTypeName ( ) const
inlinenoexcept

Get the name of the type of the request.

E.g. "connect" for connect.

◆ Keep()

virtual void wpi::uv::Request::Keep ( )
inlinevirtualnoexcept

Keep this request in memory even if no outside shared_ptr references remain.

To release call Release().

Derived classes can override this method for different memory management approaches (e.g. pooled storage of requests).

◆ operator=() [1/2]

Request & wpi::uv::Request::operator= ( const Request )
delete

◆ operator=() [2/2]

Request & wpi::uv::Request::operator= ( Request &&  )
delete

◆ RawSize()

size_t wpi::uv::Request::RawSize ( ) const
inlinenoexcept

Return the size of the underlying request type.

Returns
The size of the underlying request type.

◆ Release()

virtual std::shared_ptr< Request > wpi::uv::Request::Release ( )
inlinevirtualnoexcept

No longer force holding this request in memory.

Does not immediately destroy the object unless no outside shared_ptr references remain.

Derived classes can override this method for different memory management approaches (e.g. pooled storage of requests).

Returns
Previous shared pointer

◆ ReportError()

void wpi::uv::Request::ReportError ( int  err)
inline

Report an error.

Parameters
errError code

Member Data Documentation

◆ error

std::function<void(Error)> wpi::uv::Request::error

Error callback.

By default, this is set up to report errors to the handle that created this request.

Parameters
errerror code

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