ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

67 lines
1.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_THREAD_POOL_H
  9. #define CPPCMS_THREAD_POOL_H
  10. #include <cppcms/defs.h>
  11. #include <booster/noncopyable.h>
  12. #include <booster/function.h>
  13. #include <booster/hold_ptr.h>
  14. namespace cppcms {
  15. namespace impl {
  16. class thread_pool;
  17. }
  18. ///
  19. /// \brief This class provides an access to the thread pool where all CppCMS synchronous
  20. /// applications are executed.
  21. ///
  22. /// Users of asynchronous applications or tasks my send their jobs for the execution in the
  23. /// thread_pool
  24. ///
  25. class CPPCMS_API thread_pool : public booster::noncopyable {
  26. public:
  27. ///
  28. /// Post a request for execution of \a job in the pool. Received integer is special job identification
  29. /// number that can be used to remove the job from the queue.
  30. ///
  31. int post(booster::function<void()> const &job);
  32. ///
  33. /// Cancel the job using id received from post() function
  34. ///
  35. /// Returns true if the job was removed from the queue and false if the operation failed: the job execution is in the process
  36. /// or completed
  37. ///
  38. /// Note: the id is just a rolling number and job ids may be repeated once in a while, so it is good idea to check if the job
  39. /// was completed before cancelling the job (even it is unlikely the 4 billion jobs would be executed in small period of time.
  40. ///
  41. bool cancel(int id);
  42. /// \cond INTERNAL
  43. thread_pool(int threads);
  44. void stop();
  45. ~thread_pool();
  46. //// \endcond
  47. private:
  48. booster::hold_ptr<impl::thread_pool> impl_;
  49. };
  50. } // cppcms
  51. #endif