MXS-2002 Remove GenericFunction typedef
It does not save much in characters compared to std::function<void ()> and it's a bit misleading as not just any callable object will do, but only one that takes no argument and returns void.
This commit is contained in:
@ -496,7 +496,6 @@ public:
|
|||||||
typedef WorkerDisposableTask DisposableTask;
|
typedef WorkerDisposableTask DisposableTask;
|
||||||
typedef WorkerLoad Load;
|
typedef WorkerLoad Load;
|
||||||
typedef WorkerTimer Timer;
|
typedef WorkerTimer Timer;
|
||||||
typedef std::function<void ()> GenericFunction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A delegating timer that delegates the timer tick handling
|
* A delegating timer that delegates the timer tick handling
|
||||||
@ -759,9 +758,9 @@ public:
|
|||||||
*
|
*
|
||||||
* @return True, if task was posted to the worker
|
* @return True, if task was posted to the worker
|
||||||
*/
|
*/
|
||||||
bool execute(GenericFunction func, Semaphore* pSem, enum execute_mode_t mode);
|
bool execute(std::function<void ()> func, Semaphore* pSem, enum execute_mode_t mode);
|
||||||
|
|
||||||
bool execute(GenericFunction func, enum execute_mode_t mode)
|
bool execute(std::function<void ()> func, enum execute_mode_t mode)
|
||||||
{
|
{
|
||||||
return execute(func, NULL, mode);
|
return execute(func, NULL, mode);
|
||||||
}
|
}
|
||||||
@ -786,7 +785,7 @@ public:
|
|||||||
*
|
*
|
||||||
* @return True if function was executed on the worker.
|
* @return True if function was executed on the worker.
|
||||||
*/
|
*/
|
||||||
bool call(GenericFunction func, enum execute_mode_t mode);
|
bool call(std::function<void ()> func, enum execute_mode_t mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post a message to a worker.
|
* Post a message to a worker.
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#define WORKER_ABSENT_ID -1
|
#define WORKER_ABSENT_ID -1
|
||||||
|
|
||||||
|
using std::function;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
@ -477,20 +478,20 @@ bool Worker::post_disposable(DisposableTask* pTask, enum execute_mode_t mode)
|
|||||||
return posted;
|
return posted;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::execute(GenericFunction func, Semaphore* pSem, execute_mode_t mode)
|
bool Worker::execute(function<void ()> func, Semaphore* pSem, execute_mode_t mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
class CustomTask : public maxscale::WorkerTask
|
class CustomTask : public maxscale::WorkerTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CustomTask(GenericFunction func)
|
CustomTask(function<void ()> func)
|
||||||
: m_func(func)
|
: m_func(func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GenericFunction m_func;
|
function<void ()> m_func;
|
||||||
|
|
||||||
void execute(maxscale::Worker& worker)
|
void execute(maxscale::Worker& worker)
|
||||||
{
|
{
|
||||||
@ -522,7 +523,7 @@ bool Worker::call(Task& task, execute_mode_t mode)
|
|||||||
return execute(&task, &sem, mode) && sem.wait();
|
return execute(&task, &sem, mode) && sem.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::call(GenericFunction func, execute_mode_t mode)
|
bool Worker::call(function<void ()> func, execute_mode_t mode)
|
||||||
{
|
{
|
||||||
Semaphore sem;
|
Semaphore sem;
|
||||||
return execute(func, &sem, mode) && sem.wait();
|
return execute(func, &sem, mode) && sem.wait();
|
||||||
|
@ -191,7 +191,7 @@ private:
|
|||||||
MariaDBServer* get_server_info(MXS_MONITORED_SERVER* db);
|
MariaDBServer* get_server_info(MXS_MONITORED_SERVER* db);
|
||||||
MariaDBServer* get_server(int64_t id);
|
MariaDBServer* get_server(int64_t id);
|
||||||
MariaDBServer* get_server(SERVER* server);
|
MariaDBServer* get_server(SERVER* server);
|
||||||
bool execute_manual_command(GenericFunction command, json_t** error_out);
|
bool execute_manual_command(std::function<void ()> command, json_t** error_out);
|
||||||
std::string diagnostics_to_string() const;
|
std::string diagnostics_to_string() const;
|
||||||
json_t* diagnostics_to_json() const;
|
json_t* diagnostics_to_json() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user