Bug 1586396 - Formatting fixes in WebGPUThreading

follow-up to D48229

Differential Revision: https://phabricator.services.mozilla.com/D49367

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dzmitry Malyshau 2019-10-16 02:53:07 +00:00
Родитель f072f15267
Коммит e3328f020c
2 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@ -12,12 +12,9 @@ namespace webgpu {
static StaticRefPtr<WebGPUThreading> sWebGPUThread; static StaticRefPtr<WebGPUThreading> sWebGPUThread;
WebGPUThreading::WebGPUThreading(base::Thread* aThread) WebGPUThreading::WebGPUThreading(base::Thread* aThread) : mThread(aThread) {}
: mThread(aThread) {}
WebGPUThreading::~WebGPUThreading() { WebGPUThreading::~WebGPUThreading() { delete mThread; }
delete mThread;
}
// static // static
void WebGPUThreading::Start() { void WebGPUThreading::Start() {
@ -35,8 +32,8 @@ void WebGPUThreading::Start() {
sWebGPUThread = new WebGPUThreading(thread); sWebGPUThread = new WebGPUThreading(thread);
const auto fnInit = []() {}; const auto fnInit = []() {};
RefPtr<Runnable> runnable = NS_NewRunnableFunction( RefPtr<Runnable> runnable =
"WebGPUThreading fnInit", fnInit); NS_NewRunnableFunction("WebGPUThreading fnInit", fnInit);
sWebGPUThread->GetLoop()->PostTask(runnable.forget()); sWebGPUThread->GetLoop()->PostTask(runnable.forget());
} }
@ -45,11 +42,10 @@ void WebGPUThreading::ShutDown() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(sWebGPUThread); MOZ_ASSERT(sWebGPUThread);
const auto fnExit = []() { const auto fnExit = []() {};
};
RefPtr<Runnable> runnable = NS_NewRunnableFunction( RefPtr<Runnable> runnable =
"WebGPUThreading fnExit", fnExit); NS_NewRunnableFunction("WebGPUThreading fnExit", fnExit);
sWebGPUThread->GetLoop()->PostTask(runnable.forget()); sWebGPUThread->GetLoop()->PostTask(runnable.forget());
sWebGPUThread = nullptr; sWebGPUThread = nullptr;
@ -57,6 +53,7 @@ void WebGPUThreading::ShutDown() {
// static // static
MessageLoop* WebGPUThreading::GetLoop() { MessageLoop* WebGPUThreading::GetLoop() {
MOZ_ASSERT(NS_IsMainThread());
return sWebGPUThread ? sWebGPUThread->mThread->message_loop() : nullptr; return sWebGPUThread ? sWebGPUThread->mThread->message_loop() : nullptr;
} }

Просмотреть файл

@ -8,16 +8,17 @@
#define MOZILLA_WEBGPU_THREADING_H #define MOZILLA_WEBGPU_THREADING_H
#include "ThreadSafeRefcountingWithMainThreadDestruction.h" #include "ThreadSafeRefcountingWithMainThreadDestruction.h"
#include "base/thread.h" // for Thread #include "base/thread.h" // for Thread
#include "mozilla/layers/SynchronousTask.h" #include "mozilla/layers/SynchronousTask.h"
namespace mozilla { namespace mozilla {
namespace webgpu { namespace webgpu {
class WebGPUThreading final { class WebGPUThreading final {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(WebGPUThreading) NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(
WebGPUThreading)
public: public:
/// Can only be called from the main thread. /// Can only be called from the main thread.
static void Start(); static void Start();
@ -28,14 +29,14 @@ public:
/// the threading is not initialized. /// the threading is not initialized.
static MessageLoop* GetLoop(); static MessageLoop* GetLoop();
private: private:
explicit WebGPUThreading(base::Thread* aThread); explicit WebGPUThreading(base::Thread* aThread);
~WebGPUThreading(); ~WebGPUThreading();
base::Thread* const mThread; base::Thread* const mThread;
}; };
} } // namespace webgpu
} } // namespace mozilla
#endif // MOZILLA_WEBGPU_THREADING_H #endif // MOZILLA_WEBGPU_THREADING_H