#include <evo/ioasync_server.h>
template<class T>
struct evo::AsyncServerHandler::DeferredContextT< T >
Holds a context for deferred responses in progress.
- This is detached from the handler when the connection is destroyed, but will persist until the last deferred response so responses are cleaned up
- A protocol handler should typedef this as
DeferredContenxt
and implement DeferredReply
inheriting ReplyBase
- How it works:
- When the server creates a connection supports deferred responses it must also create a
DeferredContext
(using operator new
) and call detach() when connection is destroyed
- This holds a reference count, which starts at 1 for the connection
- detach() sets
handler=NULL
and decrements the reference count – deferred responses after that should be no-ops and just cleanup
- When a response is deferred then addref() must be called to increment the reference count
- When a deferred response is sent then endref() must be called to decrement the reference count (which will
delete this
after last deferred response if connection was destroyed)
- Template Parameters
-
T | Protocol base handler type to use, i.e. ProtocolServerHandlerBase |
|
Handler * | handler |
| Pointer to handler for sending deferred reply, NULL when connection is destroyed. More...
|
|
◆ Context
◆ Handler
◆ DeferredContextT()
◆ addref()
Call when a deferred response is started.
◆ count()
Get current pending deferred response count.
- Returns
- Pending deferred response count
◆ detach()
Call when server connection is destroyed.
- Called from server Connection destructor
- Returns
- Whether this was the last reference, meaning this is destroyed, false if not destroyed
◆ endref()
Call to cleanup after deferred response is sent/finished.
- Returns
- Whether this was the last reference, meaning this is destroyed, false if not destroyed
◆ handler
Pointer to handler for sending deferred reply, NULL when connection is destroyed.
The documentation for this struct was generated from the following file: