Skip to content

Commit 9b3cf34

Browse files
committed
Bug 1573679: Add IsCurrentThread(Explicit|Implicit)MTA utility functions to mscom; r=Jamie
This patch provides us with utility functions that give us more specific information about the current thread's MTA if so desired. Differential Revision: https://phabricator.services.mozilla.com/D41852 --HG-- extra : moz-landing-system : lando
1 parent b62f296 commit 9b3cf34

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ipc/mscom/Utils.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ bool IsCurrentThreadMTA() {
5050
return aptType == APTTYPE_MTA;
5151
}
5252

53+
bool IsCurrentThreadExplicitMTA() {
54+
APTTYPE aptType;
55+
APTTYPEQUALIFIER aptTypeQualifier;
56+
HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
57+
if (FAILED(hr)) {
58+
return false;
59+
}
60+
61+
return aptType == APTTYPE_MTA &&
62+
aptTypeQualifier != APTTYPEQUALIFIER_IMPLICIT_MTA;
63+
}
64+
65+
bool IsCurrentThreadImplicitMTA() {
66+
APTTYPE aptType;
67+
APTTYPEQUALIFIER aptTypeQualifier;
68+
HRESULT hr = CoGetApartmentType(&aptType, &aptTypeQualifier);
69+
if (FAILED(hr)) {
70+
return false;
71+
}
72+
73+
return aptType == APTTYPE_MTA &&
74+
aptTypeQualifier == APTTYPEQUALIFIER_IMPLICIT_MTA;
75+
}
76+
5377
bool IsProxy(IUnknown* aUnknown) {
5478
if (!aUnknown) {
5579
return false;

ipc/mscom/Utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace mscom {
2222

2323
bool IsCOMInitializedOnCurrentThread();
2424
bool IsCurrentThreadMTA();
25+
bool IsCurrentThreadExplicitMTA();
26+
bool IsCurrentThreadImplicitMTA();
2527
bool IsProxy(IUnknown* aUnknown);
2628
bool IsValidGUID(REFGUID aCheckGuid);
2729
uintptr_t GetContainingModuleHandle();

0 commit comments

Comments
 (0)