espthread.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*##############################################################################
  2. Copyright (C) 2011 HPCC Systems.
  3. All rights reserved. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ############################################################################## */
  14. #ifndef __ESPTHREAD_HPP__
  15. #define __ESPTHREAD_HPP__
  16. #define TERMINATE_EXITCODE -99 // the working process use it to tell the monitor to exit too.
  17. class CEspProtocolThread: public Thread
  18. {
  19. protected:
  20. bool terminating;
  21. CriticalSection sect;
  22. Semaphore ticksem;
  23. Owned<ISocket> m_socket;
  24. StringAttr m_name;
  25. int run();
  26. public:
  27. IMPLEMENT_IINTERFACE;
  28. CEspProtocolThread(const char *name = "Unkown service type");
  29. CEspProtocolThread(ISocket *sock, const char *name = "Unkown service type");
  30. virtual ~CEspProtocolThread();
  31. virtual void start();
  32. void setSocket(ISocket *sock);
  33. void stop(bool wait);
  34. virtual const char *getServiceName();
  35. virtual bool onRequest();
  36. };
  37. #endif //__ESPTHREAD_HPP__