BsCoreThreadQueue.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "CoreThread/BsCoreThreadQueue.h"
  4. #include "CoreThread/BsCommandQueue.h"
  5. #include "Material/BsMaterial.h"
  6. #include "CoreThread/BsCoreThread.h"
  7. namespace bs
  8. {
  9. CoreThreadQueueBase::CoreThreadQueueBase(CommandQueueBase* commandQueue)
  10. :mCommandQueue(commandQueue)
  11. {
  12. }
  13. CoreThreadQueueBase::~CoreThreadQueueBase()
  14. {
  15. bs_delete(mCommandQueue);
  16. }
  17. AsyncOp CoreThreadQueueBase::queueReturnCommand(std::function<void(AsyncOp&)> commandCallback)
  18. {
  19. return mCommandQueue->queueReturn(commandCallback);
  20. }
  21. void CoreThreadQueueBase::queueCommand(std::function<void()> commandCallback)
  22. {
  23. mCommandQueue->queue(commandCallback);
  24. }
  25. void CoreThreadQueueBase::submitToCoreThread(bool blockUntilComplete)
  26. {
  27. Queue<QueuedCommand>* commands = mCommandQueue->flush();
  28. gCoreThread().queueCommand(std::bind(&CommandQueueBase::playback, mCommandQueue, commands),
  29. CTQF_InternalQueue | CTQF_BlockUntilComplete);
  30. }
  31. void CoreThreadQueueBase::cancelAll()
  32. {
  33. // Note that this won't free any Frame data allocated for all the canceled commands since
  34. // frame data will only get cleared at frame start
  35. mCommandQueue->cancelAll();
  36. }
  37. }