simple_cooperative.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*************************************************************************
  2. * *
  3. * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. *
  4. * All rights reserved. Email: [email protected] Web: www.q12.org *
  5. * *
  6. * Threading base wrapper class header file. *
  7. * Copyright (C) 2011-2020 Oleh Derevenko. All rights reserved. *
  8. * e-mail: [email protected] (change all "a" to "e") *
  9. * *
  10. * This library is free software; you can redistribute it and/or *
  11. * modify it under the terms of EITHER: *
  12. * (1) The GNU Lesser General Public License as published by the Free *
  13. * Software Foundation; either version 2.1 of the License, or (at *
  14. * your option) any later version. The text of the GNU Lesser *
  15. * General Public License is included with this library in the *
  16. * file LICENSE.TXT. *
  17. * (2) The BSD-style license that is included with this library in *
  18. * the file LICENSE-BSD.TXT. *
  19. * *
  20. * This library is distributed in the hope that it will be useful, *
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
  23. * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
  24. * *
  25. *************************************************************************/
  26. /*
  27. * A simple cooperative class definition
  28. * Copyright (c) 2017-2020 Oleh Derevenko, [email protected] (change all "a" to "e")
  29. */
  30. #ifndef _ODE__PRIVATE_SIMPLE_COOPERATIVE_H_
  31. #define _ODE__PRIVATE_SIMPLE_COOPERATIVE_H_
  32. #include "objects.h"
  33. #include "threading_base.h"
  34. typedef dxThreadingBase dxSimpleCooperative_ThreadingParent;
  35. class dxSimpleCooperative:
  36. public dBase,
  37. public dxSimpleCooperative_ThreadingParent,
  38. private dxIThreadingDefaultImplProvider
  39. {
  40. public:
  41. dxSimpleCooperative(const dxThreadingFunctionsInfo *functionInfo, dThreadingImplementationID threadingImpl):
  42. dBase(),
  43. dxSimpleCooperative_ThreadingParent()
  44. {
  45. dxSimpleCooperative_ThreadingParent::setThreadingDefaultImplProvider(this);
  46. dxSimpleCooperative_ThreadingParent::assignThreadingImpl(functionInfo, threadingImpl);
  47. }
  48. virtual ~dxSimpleCooperative();
  49. public:
  50. dxThreadingBase *getRelatedThreading() const { return const_cast<dxSimpleCooperative *>(this); }
  51. private: // dxIThreadingDefaultImplProvider
  52. virtual const dxThreadingFunctionsInfo *retrieveThreadingDefaultImpl(dThreadingImplementationID &out_defaultImpl);
  53. };
  54. static inline
  55. dxSimpleCooperative *decodeCooperativeID(dCooperativeID cooperative)
  56. {
  57. return (dxSimpleCooperative *)cooperative;
  58. }
  59. #endif // #ifndef _ODE__PRIVATE_SIMPLE_COOPERATIVE_H_