QueueObject.cpp 875 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "QueueObject.h"
  6. #include "mozilla/AbstractThread.h"
  7. #include "mozilla/TaskQueue.h"
  8. #include "nsThreadUtils.h"
  9. namespace mozilla {
  10. QueueObject::QueueObject(RefPtr<AbstractThread> aThread) : mThread(aThread) {}
  11. QueueObject::~QueueObject() {}
  12. void
  13. QueueObject::Dispatch(nsIRunnable* aRunnable)
  14. {
  15. Dispatch(do_AddRef(aRunnable));
  16. }
  17. void
  18. QueueObject::Dispatch(already_AddRefed<nsIRunnable> aRunnable)
  19. {
  20. mThread->Dispatch(Move(aRunnable));
  21. }
  22. bool
  23. QueueObject::OnThread()
  24. {
  25. return mThread->IsCurrentThreadIn();
  26. }
  27. AbstractThread*
  28. QueueObject::Thread()
  29. {
  30. return mThread;
  31. }
  32. }