VLink  2.0.0
A high-performance communication middleware
vlink::ClientImpl类 参考abstract

Connection-aware base class for method-model client implementations. 更多...

#include <client_impl.h>

类 vlink::ClientImpl 继承关系图:
vlink::ClientImpl 的协作图:

Public 成员函数

 ~ClientImpl () override
 Releases the helper state held by the base class. 更多...
 
void interrupt () override
 Wakes blocked waiters and forwards the interrupt to NodeImpl. 更多...
 
virtual void detect_connected (ConnectCallback &&callback)
 Registers callback to fire whenever the server presence changes. 更多...
 
virtual bool wait_for_connected (std::chrono::milliseconds timeout)
 Blocks until a server becomes reachable or timeout elapses. 更多...
 
virtual bool is_connected () const =0
 Reports whether the transport currently holds a path to a server. 更多...
 
virtual bool call (const Bytes &req_data, MsgCallback &&callback, std::chrono::milliseconds timeout)=0
 Performs a synchronous round-trip with the remote server. 更多...
 
void update_connected ()
 Notifies the base class that the underlying connection state may have changed. 更多...
 

Public 属性

bool is_resp_type {false}
 true when the public Client expects a response payload. 更多...
 

Protected 成员函数

 ClientImpl ()
 Stamps the node as kClient and prepares the helper state. 更多...
 

额外继承的成员函数

详细描述

Connection-aware base class for method-model client implementations.

Owns the helper condition variable used by wait_for_connected() and the cached ConnectCallback delivered via detect_connected(). Backends are expected to push presence updates by calling update_connected() whenever the discovery layer reports a server appear / disappear event.

构造及析构函数说明

◆ ~ClientImpl()

vlink::ClientImpl::~ClientImpl ( )
override

Releases the helper state held by the base class.

◆ ClientImpl()

vlink::ClientImpl::ClientImpl ( )
protected

Stamps the node as kClient and prepares the helper state.

成员函数说明

◆ call()

virtual bool vlink::ClientImpl::call ( const Bytes req_data,
MsgCallback &&  callback,
std::chrono::milliseconds  timeout 
)
pure virtual

Performs a synchronous round-trip with the remote server.

Pure virtual; subclasses send req_data, wait for the matching response (typically through AckManager) and invoke callback with the received bytes once a frame arrives.

参数
req_dataSerialised request payload.
callbackCallable void(const Bytes&) receiving the response bytes.
timeoutMaximum wait duration; negative for unlimited.
返回
true on success; false on timeout, interruption or transport error.

◆ detect_connected()

virtual void vlink::ClientImpl::detect_connected ( ConnectCallback &&  callback)
virtual

Registers callback to fire whenever the server presence changes.

If the connection is already established at registration time, callback is invoked with true before this method returns. Subsequent transitions are forwarded by update_connected().

参数
callbackCallable void(bool) to be notified on connect / disconnect.

◆ interrupt()

void vlink::ClientImpl::interrupt ( )
overridevirtual

Wakes blocked waiters and forwards the interrupt to NodeImpl.

Marks the node interrupted, notifies the helper condition variable so any wait_for_connected() call returns false promptly, and delegates the rest of the shutdown handshake to NodeImpl::interrupt(). Transport subclasses commonly override this to also cancel pending AckManager requests.

重载 vlink::NodeImpl .

◆ is_connected()

virtual bool vlink::ClientImpl::is_connected ( ) const
pure virtual

Reports whether the transport currently holds a path to a server.

Pure virtual; subclasses query their underlying discovery handle. Called by both wait_for_connected() and update_connected() to compute state transitions.

返回
true when a server is reachable; false otherwise.

◆ update_connected()

void vlink::ClientImpl::update_connected ( )

Notifies the base class that the underlying connection state may have changed.

Compares is_connected() against the helper cache; when the value flips the condition variable is signalled and any registered ConnectCallback is delivered. Intended to run on the transport's discovery / listener thread, not on the application thread.

◆ wait_for_connected()

virtual bool vlink::ClientImpl::wait_for_connected ( std::chrono::milliseconds  timeout)
virtual

Blocks until a server becomes reachable or timeout elapses.

Returns immediately when is_connected() already reports true. Otherwise sleeps on the helper condition variable that is poked by update_connected() and by interrupt(). A negative timeout, such as Timeout::kInfinite, disables the deadline.

参数
timeoutMaximum sleep duration.
返回
true when the server appeared in time; false on timeout or interruption.

类成员变量说明

◆ is_resp_type

bool vlink::ClientImpl::is_resp_type {false}

true when the public Client expects a response payload.


该类的文档由以下文件生成: