thorhelper.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef THORHELPER_HPP
  14. #define THORHELPER_HPP
  15. #include "jiface.hpp"
  16. #include "jptree.hpp"
  17. #include "jthread.hpp"
  18. #ifdef THORHELPER_EXPORTS
  19. #define THORHELPER_API DECL_EXPORT
  20. #else
  21. #define THORHELPER_API DECL_IMPORT
  22. #endif
  23. interface IXmlToRawTransformer : extends IInterface
  24. {
  25. virtual IDataVal & transform(IDataVal & result, size32_t len, const void * text, bool isDataset) = 0;
  26. virtual IDataVal & transformTree(IDataVal & result, IPropertyTree &tree, bool isDataset) = 0;
  27. };
  28. interface ICsvToRawTransformer : extends IInterface
  29. {
  30. virtual IDataVal & transform(IDataVal & result, size32_t len, const void * text, bool isDataset) = 0;
  31. };
  32. enum ThorReplyCodes { DAMP_THOR_ACK, DAMP_THOR_REPLY_GOOD, DAMP_THOR_REPLY_ERROR, DAMP_THOR_REPLY_ABORT, DAMP_THOR_REPLY_PAUSED };
  33. // Similar to CThreadedPersistent, but using tbb
  34. #ifdef _USE_TBB
  35. namespace tbb
  36. {
  37. class task;
  38. }
  39. class THORHELPER_API CPersistentTask
  40. {
  41. private:
  42. Owned<IException> exception;
  43. IThreaded *owner;
  44. tbb::task * end = nullptr;
  45. void threadmain();
  46. public:
  47. CPersistentTask(const char *name, IThreaded *_owner);
  48. void start();
  49. bool join(unsigned timeout=INFINITE, bool throwException = true);
  50. };
  51. #else
  52. typedef CThreadedPersistent CPersistentTask;
  53. #endif
  54. #endif // THORHELPER_HPP