Add more session command related functions to Backend
The class now allows simpler construction of session commands by overloading the add_session_command with a version that accepts a const reference to a shared pointer. This removes the need to copy the references to the source buffer by calling gwbuf_clone. Exposed the first session command as a const reference to allow interaction with it. Currently, it is planned to be used to get the session command position of each backend.
This commit is contained in:
@ -73,6 +73,7 @@ public:
|
|||||||
* the session command is completed
|
* the session command is completed
|
||||||
*/
|
*/
|
||||||
void add_session_command(GWBUF* buffer, uint64_t sequence);
|
void add_session_command(GWBUF* buffer, uint64_t sequence);
|
||||||
|
void add_session_command(const SSessionCommand& sescmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Mark the current session command as successfully executed
|
* @brief Mark the current session command as successfully executed
|
||||||
@ -90,6 +91,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
size_t session_command_count() const;
|
size_t session_command_count() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the first session command
|
||||||
|
*
|
||||||
|
* Returns the first session command in the list of session commands
|
||||||
|
* to be executed.
|
||||||
|
*
|
||||||
|
* This should only be called when at least one session command has been
|
||||||
|
* added to the backend. If no session commands have been added, behavior
|
||||||
|
* is undefined.
|
||||||
|
*
|
||||||
|
* @return The first session command
|
||||||
|
*/
|
||||||
|
const SSessionCommand& next_session_command() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get pointer to server reference
|
* @brief Get pointer to server reference
|
||||||
*
|
*
|
||||||
|
@ -116,6 +116,11 @@ void Backend::add_session_command(GWBUF* buffer, uint64_t sequence)
|
|||||||
m_session_commands.push_back(SSessionCommand(new SessionCommand(buffer, sequence)));
|
m_session_commands.push_back(SSessionCommand(new SessionCommand(buffer, sequence)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Backend::add_session_command(const SSessionCommand& sescmd)
|
||||||
|
{
|
||||||
|
m_session_commands.push_back(sescmd);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Backend::complete_session_command()
|
uint64_t Backend::complete_session_command()
|
||||||
{
|
{
|
||||||
uint64_t rval = m_session_commands.front()->get_position();
|
uint64_t rval = m_session_commands.front()->get_position();
|
||||||
@ -128,6 +133,12 @@ size_t Backend::session_command_count() const
|
|||||||
return m_session_commands.size();
|
return m_session_commands.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SSessionCommand& Backend::next_session_command() const
|
||||||
|
{
|
||||||
|
ss_dassert(session_command_count() > 0);
|
||||||
|
return m_session_commands.front();
|
||||||
|
}
|
||||||
|
|
||||||
void Backend::clear_state(backend_state state)
|
void Backend::clear_state(backend_state state)
|
||||||
{
|
{
|
||||||
if ((state & WAITING_RESULT) && (m_state & WAITING_RESULT))
|
if ((state & WAITING_RESULT) && (m_state & WAITING_RESULT))
|
||||||
|
Reference in New Issue
Block a user