MXS-2008 Provide single entrypoint for initializing maxbase

Everything of maxbase can now be initialized by a call to

    maxbase_init();

(from a C-program) or

    maxbase::init();

from a C++-program and finalized with calls to either
maxbase_finish() or maxbase::finish(). Creating an instance
maxbase::MaxBase will take care of both operations.
This commit is contained in:
Johan Wikman
2018-08-20 14:29:22 +03:00
parent 88f1795412
commit e852dcacdd
9 changed files with 324 additions and 36 deletions

View File

@ -18,6 +18,7 @@
namespace maxbase
{
class MaxBase;
class MessageQueue;
class Worker;
@ -116,21 +117,6 @@ public:
typedef MessageQueueHandler Handler;
typedef MessageQueueMessage Message;
/**
* Initializes the message queue mechanism. To be called once at
* process startup.
*
* @return True if the initialization succeeded, false otherwise.
*/
static bool init();
/**
* Finalizes the message queue mechanism. To be called once at
* process shutdown, if the initialization succeeded.
*/
static void finish();
/**
* Creates a @c MessageQueue with the provided handler.
*
@ -190,6 +176,12 @@ public:
*/
Worker* remove_from_worker();
public:
// TODO: Make private once all callers have been modified.
friend class MaxBase;
static bool init();
static void finish();
private:
MessageQueue(Handler* pHandler, int read_fd, int write_fd);