msgPump 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # -*- mode: snippet -*-
  2. # name: Message pump
  3. # key: msgPump
  4. # group: col
  5. # --
  6. #include <functional>
  7. #include <thread>
  8. #include <memory>
  9. #include "Queue.hpp"
  10. /**
  11. * \class ${1:`(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`}
  12. * \brief short description of class $1
  13. *
  14. *
  15. * $0 This class runs asynchronous, this should be a longer description.
  16. * \addtogroup $1
  17. */
  18. class $1
  19. {
  20. public:
  21. /**
  22. * \name constructor
  23. * \brief constructor for $1
  24. */
  25. $1(){}
  26. /**
  27. * \name destructor
  28. * \brief destructor for $1
  29. */
  30. ~$1(){}
  31. /**
  32. * Typedef for message pump function, these are to
  33. * placed in the message queue
  34. */
  35. typedef std::function< bool () > FunT;
  36. /**
  37. * Typedef message queue, where functions are placed
  38. */
  39. typedef Util::Queue< FunT > FunctionMsgQueueT;
  40. /**
  41. * Typedef shared pointer type for threads
  42. */
  43. typedef std::shared_ptr< std::thread > ThreadPtrT;
  44. /**
  45. * \brief $2 short description
  46. *
  47. * $2 Longer description
  48. */
  49. void ${2:startSystem}();
  50. /**
  51. * \brief $3 short description
  52. *
  53. * $3 Longer description
  54. */
  55. void ${3:stopSystem}();
  56. /**
  57. * \name $4
  58. * \brief get method for the current thread
  59. *
  60. * Returns the current thread for the $1
  61. * \return ThreadPtrT
  62. */
  63. ThreadPtrT ${4:getThread}() const;
  64. private:
  65. /**
  66. * \brief Thread runnable method
  67. *
  68. * This message is where the thread is executing.
  69. */
  70. void ${5:run}();
  71. /** Current thread */
  72. ThreadPtrT ${6:itsThread_};
  73. /** Current message queue*/
  74. FunctionMsgQueueT ${7:itsQueue_};
  75. };