Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. class threadDelegator {
  2. public:
  3. threadDelegator(std::size_t const maxSize = 20);
  4. threadDelegator(threadDelegator const& copy) = delete;
  5. threadDelegator &operator=(threadDelegator const& copy) = delete;
  6. bool delegateTask(ISocket *sock);
  7. inline std::size_t getNbrWorkers() const;
  8. inline bool isFull() const;
  9. template<typename Function>
  10. void launchThreadById(std::size_t id, Function &&f) const;
  11. private:
  12. void m_create_thread(ISocket *sock);
  13. void m_flush_queue();
  14. private:
  15. using ptr_thread_t = std::unique_ptr<threadGuard>;
  16. using ptr_queue_t = std::unique_ptr<taskQueue<ISocket *>>;
  17. std::size_t maxSize_;
  18. std::vector<ptr_thread_t> workers_;
  19. ptr_queue_t tasks_;
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement