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