#ifndef __ASYNCEVENT_H__ #define __ASYNCEVENT_H__ #include "rw_zlog.h" #include #include #include class AsyncEvent : public QEvent { public: using Functor = std::function; AsyncEvent(Functor &&functor) : QEvent(static_cast(QEvent::registerEventType())), m_functor(std::forward(functor)) { } ~AsyncEvent() { if (QCoreApplication::closingDown()) { LOGW("QCoreApplication closed,skip handle task."); return; } if (m_functor) m_functor(); } private: Functor m_functor; }; #endif // __ASYNCEVENT_H__