Add is_active helper to Backend

The Backend now provides a helper function for checking if the SERFER_REF
is still active.

Also renamed the close_type enum values.
This commit is contained in:
Markus Mäkelä
2017-06-15 16:27:04 +03:00
parent 5a5effdf7a
commit c3c905f745
2 changed files with 16 additions and 4 deletions

View File

@ -36,8 +36,8 @@ public:
*/ */
enum close_type enum close_type
{ {
NORMAL, CLOSE_NORMAL,
FATAL CLOSE_FATAL
}; };
/** /**
@ -125,7 +125,7 @@ public:
* *
* This will close all active connections created by the backend. * This will close all active connections created by the backend.
*/ */
void close(close_type type = NORMAL); void close(close_type type = CLOSE_NORMAL);
/** /**
* @brief Get a pointer to the internal DCB * @brief Get a pointer to the internal DCB
@ -182,6 +182,13 @@ public:
*/ */
bool in_use() const; bool in_use() const;
/**
* @brief Check if the backend server reference is active
*
* @return True if the server reference is active
*/
bool is_active() const;
/** /**
* @brief Check if backend is waiting for a result * @brief Check if backend is waiting for a result
* *

View File

@ -53,7 +53,7 @@ void Backend::close(close_type type)
clear_state(IN_USE); clear_state(IN_USE);
set_state(CLOSED); set_state(CLOSED);
if (type == FATAL) if (type == CLOSE_FATAL)
{ {
set_state(FATAL_FAILURE); set_state(FATAL_FAILURE);
} }
@ -248,6 +248,11 @@ bool Backend::in_use() const
return m_state & IN_USE; return m_state & IN_USE;
} }
bool Backend::is_active() const
{
return SERVER_REF_IS_ACTIVE(m_backend);
}
bool Backend::is_waiting_result() const bool Backend::is_waiting_result() const
{ {
return m_state & WAITING_RESULT; return m_state & WAITING_RESULT;