Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include<memory>
- #include<map>
- #include<boost/bind.hpp>
- #include<boost/asio/io_service.hpp>
- #include<boost/thread.hpp>
- namespace NB
- {
- class IModule
- {
- public:
- virtual void doWork() = 0;
- };
- class ModulableThreadPool
- {
- public:
- enum ThreadModulePriority
- {
- TP_Lowest = 1,
- TP_Low,
- TP_Normal,
- TP_High,
- TP_Highest,
- };
- typedef std::multimap<ThreadModulePriority, IModule*> ModuleList;
- ModulableThreadPool(uint32_t threads = 1);
- ~ModulableThreadPool();
- void registerModule(IModule* module, ThreadModulePriority = TP_Normal);
- void unregisterModule(IModule* module);
- private:
- boost::asio::io_service m_ioService;
- boost::thread_group m_threadPool;
- boost::asio::io_service::work m_ioWork;
- boost::thread* m_schedulerThread;
- void schedulerFunc();
- ModuleList m_registeredModules;
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement