Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class threadDelegator {
- public:
- threadDelegator(std::size_t const maxSize = 20);
- threadDelegator(threadDelegator const& copy) = delete;
- threadDelegator &operator=(threadDelegator const& copy) = delete;
- bool delegateTask(ISocket *sock);
- inline std::size_t getNbrWorkers() const;
- inline bool isFull() const;
- template<typename Function>
- void launchThreadById(std::size_t id, Function &&f) const;
- private:
- void m_create_thread(ISocket *sock);
- void m_flush_queue();
- private:
- using ptr_thread_t = std::unique_ptr<threadGuard>;
- using ptr_queue_t = std::unique_ptr<taskQueue<ISocket *>>;
- std::size_t maxSize_;
- std::vector<ptr_thread_t> workers_;
- ptr_queue_t tasks_;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement