#pragma once
#include <iostream>
using namespace std;
#include <functional>
#include <vector>
#include <sys/types.h>
#include <unistd.h>
#include <unordered_map>
typedef function<void()> func;
vector<func> callbacks;
unordered_map<size_t, string> desc;
void readMySQL()
{
cout << "process[" << getpid() << "]执行访问数据库的任务" << endl;
}
void execuleUrl()
{
cout << "process[" << getpid() << "]执行url解析" << endl;
}
void cal()
{
cout << "process[" << getpid() << "]执行加密任务" << endl;
}
void save()
{
cout << "process[" << getpid() << "]执行数据持久化任务" << endl;
}
void load()
{
desc.insert({callbacks.size(), "readMySQL"});
callbacks.push_back(readMySQL);
desc.insert({callbacks.size(), "execuleUrl"});
callbacks.push_back(execuleUrl);
desc.insert({callbacks.size(), "cal"});
callbacks.push_back(cal);
desc.insert({callbacks.size(), "save"});
callbacks.push_back(save);
}
void showHandler()
{
for (auto e : desc)
{
cout << e.first << "--" << e.second << endl;
}
}