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.
 
 
 
 
 
 

69 lines
1.3 KiB

  1. #ifndef CPPCMS_AIO_TIMER_H
  2. #define CPPCMS_AIO_TIMER_H
  3. #include "defs.h"
  4. #include "noncopyable.h"
  5. #include "callback1.h"
  6. #include "hold_ptr.h"
  7. namespace cppcms {
  8. class service;
  9. namespace aio {
  10. ///
  11. /// \brief timer is a class that is used to run asynchronous requests after certain time period
  12. ///
  13. class CPPCMS_API timer : public util::noncopyable {
  14. public:
  15. ///
  16. /// Create a timer, it recieves the service as parameter
  17. ///
  18. timer(service &srv);
  19. ~timer();
  20. typedef util::callback1<bool> handler;
  21. //
  22. // true if was error or cancelation
  23. //
  24. ///
  25. /// Start asynchronous wait procedure. handler \a h will be called with true if error
  26. /// had occured or the timer was stopped.
  27. ///
  28. /// Should be called after expires_from_now or expires_at were called.
  29. ///
  30. /// You should call them each time before \a async_wait is called
  31. ///
  32. void async_wait(handler const &h);
  33. ///
  34. /// Abort timer
  35. ///
  36. void cancel();
  37. ///
  38. /// Set expiration time in seconds
  39. ///
  40. void expires_from_now(int seconds);
  41. ///
  42. /// Set expiration time in miliseconds
  43. ///
  44. void expires_from_now(int seconds,int milliseconds);
  45. ///
  46. /// Set expiration point. At should be in future
  47. ///
  48. void expires_at(time_t at);
  49. private:
  50. struct data;
  51. util::hold_ptr<data> d;
  52. };
  53. }
  54. }
  55. #endif