#pragma once #include #include #include #include class TcpServiceDetail; class IOLoopData : public NonCopyable, public std::enable_shared_from_this { public: using Ptr = std::shared_ptr; static Ptr Create(EventLoop::Ptr eventLoop, std::shared_ptr ioThread) { class make_shared_enabler : public IOLoopData { public: make_shared_enabler(EventLoop::Ptr eventLoop, std::shared_ptr ioThread) : IOLoopData(std::move(eventLoop), std::move(ioThread)) {} }; return std::make_shared(std::move(eventLoop), std::move(ioThread)); } const EventLoop::Ptr &getEventLoop() const { return mEventLoop; } protected: const std::shared_ptr &getIOThread() const { return mIOThread; } IOLoopData(EventLoop::Ptr eventLoop, std::shared_ptr ioThread) : mEventLoop(std::move(eventLoop)), mIOThread(std::move(ioThread)) {} virtual ~IOLoopData() = default; const EventLoop::Ptr mEventLoop; private: std::shared_ptr mIOThread; friend class TcpServiceDetail; }; using IOLoopDataPtr = std::shared_ptr;