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/. */
7 #include "mozilla/ProfilerThreadRegistry.h"
9 namespace mozilla::profiler
{
12 MOZ_RUNINIT
ThreadRegistry::RegistryContainer
13 ThreadRegistry::sRegistryContainer
;
16 MOZ_RUNINIT
ThreadRegistry::RegistryMutex
ThreadRegistry::sRegistryMutex
;
18 #if !defined(MOZ_GECKO_PROFILER)
19 // When MOZ_GECKO_PROFILER is not defined, the function definitions in
20 // platform.cpp are not built, causing link errors. So we keep these simple
24 void ThreadRegistry::Register(ThreadRegistration::OnThreadRef aOnThreadRef
) {
26 MOZ_RELEASE_ASSERT(sRegistryContainer
.append(OffThreadRef
{aOnThreadRef
}));
30 void ThreadRegistry::Unregister(ThreadRegistration::OnThreadRef aOnThreadRef
) {
32 for (OffThreadRef
& thread
: sRegistryContainer
) {
33 if (thread
.IsPointingAt(*aOnThreadRef
.mThreadRegistration
)) {
34 sRegistryContainer
.erase(&thread
);
39 #endif // !defined(MOZ_GECKO_PROFILER)
41 } // namespace mozilla::profiler