MySQL 8.4.2
Source Code Documentation
AwaitClientOrServerProcessor Class Reference

#include <await_client_or_server.h>

Inheritance diagram for AwaitClientOrServerProcessor:
[legend]

Public Types

enum class  AwaitResult { ClientReadable , ServerReadable }
 
- Public Types inherited from BasicProcessor
enum class  Result {
  Again , RecvFromClient , SendToClient , RecvFromServer ,
  RecvFromBoth , SendToServer , SendableToServer , Suspend ,
  Done , Void
}
 

Public Member Functions

 AwaitClientOrServerProcessor (MysqlRoutingClassicConnectionBase *conn, std::function< void(stdx::expected< AwaitResult, std::error_code >)> on_done)
 
stdx::expected< Result, std::error_code > process () override
 
- Public Member Functions inherited from BasicProcessor
 BasicProcessor (MysqlRoutingClassicConnectionBase *conn)
 
virtual ~BasicProcessor ()=default
 
const MysqlRoutingClassicConnectionBaseconnection () const
 
MysqlRoutingClassicConnectionBaseconnection ()
 

Private Types

enum class  Stage {
  Init , WaitBoth , WaitClientCancelled , WaitServerCancelled ,
  Done
}
 

Private Member Functions

void stage (Stage stage)
 
Stage stage () const
 
stdx::expected< Result, std::error_code > init ()
 
stdx::expected< Result, std::error_code > wait_both ()
 wait for an read-event from client and server at the same time. More...
 
stdx::expected< Result, std::error_code > wait_client_cancelled ()
 read-event from server while waiting for client command. More...
 
stdx::expected< Result, std::error_code > wait_server_cancelled ()
 

Private Attributes

Stage stage_ {Stage::Init}
 
std::function< void(stdx::expected< AwaitResult, std::error_code >)> on_done_
 

Member Enumeration Documentation

◆ AwaitResult

Enumerator
ClientReadable 
ServerReadable 

◆ Stage

enum class AwaitClientOrServerProcessor::Stage
strongprivate
Enumerator
Init 
WaitBoth 
WaitClientCancelled 
WaitServerCancelled 
Done 

Constructor & Destructor Documentation

◆ AwaitClientOrServerProcessor()

AwaitClientOrServerProcessor::AwaitClientOrServerProcessor ( MysqlRoutingClassicConnectionBase conn,
std::function< void(stdx::expected< AwaitResult, std::error_code >)>  on_done 
)
inline

Member Function Documentation

◆ init()

stdx::expected< Processor::Result, std::error_code > AwaitClientOrServerProcessor::init ( )
private

◆ process()

stdx::expected< Processor::Result, std::error_code > AwaitClientOrServerProcessor::process ( )
overridevirtual

Implements BasicProcessor.

◆ stage() [1/2]

Stage AwaitClientOrServerProcessor::stage ( ) const
inlineprivate

◆ stage() [2/2]

void AwaitClientOrServerProcessor::stage ( Stage  stage)
inlineprivate

◆ wait_both()

stdx::expected< Processor::Result, std::error_code > AwaitClientOrServerProcessor::wait_both ( )
private

wait for an read-event from client and server at the same time.

two async-reads have been started, which both will call wait_both(). Only one of the two should continue.

To ensure that event handlers are properly synchronized:

  • the first returning event, cancels the other waiter and leaves without "returning" (Void)
  • the cancelled side, continues with executing.

◆ wait_client_cancelled()

stdx::expected< Processor::Result, std::error_code > AwaitClientOrServerProcessor::wait_client_cancelled ( )
private

read-event from server while waiting for client command.

  • either a connection-close by the server or
  • ERR packet before connection-close.

◆ wait_server_cancelled()

stdx::expected< Processor::Result, std::error_code > AwaitClientOrServerProcessor::wait_server_cancelled ( )
private

Member Data Documentation

◆ on_done_

std::function<void(stdx::expected<AwaitResult, std::error_code>)> AwaitClientOrServerProcessor::on_done_
private

◆ stage_

Stage AwaitClientOrServerProcessor::stage_ {Stage::Init}
private

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