1 /* -*- Mode: C++; tab-width: 2; 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 "SyncProfile.h"
8 #include "UnwinderThread2.h"
10 SyncProfile::SyncProfile(ThreadInfo
* aInfo
, int aEntrySize
)
11 : ThreadProfile(aInfo
, aEntrySize
)
12 , mOwnerState(REFERENCED
)
15 MOZ_COUNT_CTOR(SyncProfile
);
18 SyncProfile::~SyncProfile()
20 MOZ_COUNT_DTOR(SyncProfile
);
22 utb__release_sync_buffer(mUtb
);
24 Sampler::FreePlatformData(GetPlatformData());
28 SyncProfile::SetUWTBuffer(LinkedUWTBuffer
* aBuff
)
36 SyncProfile::ShouldDestroy()
38 GetMutex()->AssertNotCurrentThreadOwns();
39 mozilla::MutexAutoLock
lock(*GetMutex());
40 if (mOwnerState
== OWNED
) {
41 mOwnerState
= OWNER_DESTROYING
;
44 mOwnerState
= ORPHANED
;
49 SyncProfile::EndUnwind()
51 // Mutex must be held when this is called
52 GetMutex()->AssertCurrentThreadOwns();
54 utb__end_sync_buffer_unwind(mUtb
);
56 if (mOwnerState
!= ORPHANED
) {
60 // Save mOwnerState before we release the mutex
61 OwnerState ownerState
= mOwnerState
;
62 ThreadProfile::EndUnwind();
63 if (ownerState
== ORPHANED
) {