MXS-2218 Add housekeeper functionality to MainWorker

In preparation for moving the housekeeper functionality on top
of MainWorker.
This commit is contained in:
Johan Wikman
2019-01-07 15:03:00 +02:00
parent c5a4f2abdd
commit 92306c565b
2 changed files with 84 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include <maxscale/ccdefs.hh>
#include <maxbase/worker.hh>
#include <maxscale/housekeeper.h>
namespace maxscale
{
@ -41,10 +42,34 @@ public:
*/
static MainWorker& get();
void add_task(const char* zName, TASKFN func, void* pData, int frequency);
void remove_task(const char* zName);
private:
bool pre_run() override;
void post_run() override;
void epoll_tick() override;
struct Task
{
public:
Task(const char* zName, TASKFN func, void* pData)
: name(zName)
, func(func)
, pData(pData)
, id(0)
{
};
std::string name;
TASKFN func;
void* pData;
uint32_t id;
};
bool call_task(Worker::Call::action_t action, Task* pTask);
std::map<std::string, Task> m_tasks_by_name;
};
}