BsAsyncOpEx.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //********************************** Banshee Engine (www.banshee4d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "BsScriptObject.h"
  6. #include "Threading/BsAsyncOp.h"
  7. namespace bs
  8. {
  9. /** @addtogroup ScriptInteropEngine
  10. * @{
  11. */
  12. /** @cond SCRIPT_EXTENSIONS */
  13. /**
  14. * Object you may use to check on the results of an asynchronous operation. Contains uninitialized data until
  15. * IsComplete returns true.
  16. */
  17. class BS_SCR_BE_EXPORT BS_SCRIPT_EXPORT(n:AsyncOp) AsyncOpEx
  18. {
  19. public:
  20. AsyncOpEx(const AsyncOp& op, const std::function<MonoObject*(const AsyncOp&)>& convertCallback);
  21. /** @copydoc AsyncOp::hasCompleted */
  22. BS_SCRIPT_EXPORT(n:IsComplete,pr:getter)
  23. bool isComplete() const;
  24. /** Retrieves the value returned by the async operation. Only valid if IsComplete returns true. */
  25. BS_SCRIPT_EXPORT(n:ReturnValue,pr:getter)
  26. MonoObject* getReturnValue() const;
  27. /** @copydoc AsyncOp::blockUntilComplete */
  28. BS_SCRIPT_EXPORT(n:BlockUntilComplete)
  29. void blockUntilComplete() const;
  30. private:
  31. AsyncOp mAsyncOp;
  32. std::function<MonoObject*(const AsyncOp&)> mConvertCallback;
  33. };
  34. /** @endcond */
  35. /** @} */
  36. }