Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=99: */
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 "VsyncIOThreadHolder.h"
8 :
9 : namespace mozilla {
10 : namespace gfx {
11 :
12 0 : VsyncIOThreadHolder::VsyncIOThreadHolder()
13 : {
14 0 : MOZ_COUNT_CTOR(VsyncIOThreadHolder);
15 0 : }
16 :
17 0 : VsyncIOThreadHolder::~VsyncIOThreadHolder()
18 : {
19 0 : MOZ_COUNT_DTOR(VsyncIOThreadHolder);
20 :
21 0 : if (!mThread) {
22 0 : return;
23 : }
24 :
25 0 : if (NS_IsMainThread()) {
26 0 : mThread->AsyncShutdown();
27 : } else {
28 0 : NS_DispatchToMainThread(NewRunnableMethod(
29 0 : "nsIThread::AsyncShutdown", mThread, &nsIThread::AsyncShutdown));
30 : }
31 0 : }
32 :
33 : bool
34 0 : VsyncIOThreadHolder::Start()
35 : {
36 0 : nsresult rv = NS_NewNamedThread("VsyncIOThread", getter_AddRefs(mThread));
37 0 : return NS_SUCCEEDED(rv);
38 : }
39 :
40 : RefPtr<nsIThread>
41 0 : VsyncIOThreadHolder::GetThread() const
42 : {
43 0 : return mThread;
44 : }
45 :
46 : } // namespace gfx
47 9 : } // namespace mozilla
|