注:Semaphore.h源码见https://mp.csdn.net/console/editor/html/103927034
TimeEvent.h
/**
* desp: time event
* auth: wangkui
* date: 2020/01/09
*/
#ifndef __TIMEEVENT_H__
#define __TIMEEVENT_H__
#include <functional>
#include <list>
#include <memory>
#include <mutex>
#include <thread>
#include <unistd.h>
#include <algorithm>
#include <atomic>
#include "Semaphore.h"
/*delay单位为ms,callback耗时较长,请使用独立线程*/
#define REGISTER_EVENT(callback, param, delay) TimeEvent::getInstance()->registerEvent(callback, param, delay)
//#define REGISTER_EVENT_PERMANENT(callbac