ProcessRuntimeShared.cpp (1103B)
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 "mozilla/mscom/ProcessRuntimeShared.h" 8 9 #include "mozilla/glue/WinUtils.h" 10 11 // We allow multiple ProcessRuntime instances to exist simultaneously (even 12 // on separate threads), but only one should be doing the process-wide 13 // initialization. These variables provide that mutual exclusion. 14 static mozilla::glue::Win32SRWLock gLock; 15 static mozilla::mscom::detail::ProcessInitState gProcessInitState = 16 mozilla::mscom::detail::ProcessInitState::Uninitialized; 17 18 namespace mozilla { 19 namespace mscom { 20 namespace detail { 21 22 MFBT_API ProcessInitState& BeginProcessRuntimeInit() { 23 gLock.LockExclusive(); 24 return gProcessInitState; 25 } 26 27 MFBT_API void EndProcessRuntimeInit() { gLock.UnlockExclusive(); } 28 29 } // namespace detail 30 } // namespace mscom 31 } // namespace mozilla