Bug 1294903: Add a default constructor to mscom::EnsureMTA that ensures that the MTA thread is running; r?jimm
MozReview-Commit-ID: IN4maTgdL4l
--- a/ipc/mscom/EnsureMTA.h
+++ b/ipc/mscom/EnsureMTA.h
@@ -21,16 +21,26 @@
namespace mozilla {
namespace mscom {
// This class is OK to use as a temporary on the stack.
class MOZ_STACK_CLASS EnsureMTA
{
public:
+ /**
+ * This constructor just ensures that the MTA thread is up and running.
+ */
+ EnsureMTA()
+ {
+ MOZ_ASSERT(NS_IsMainThread());
+ nsCOMPtr<nsIThread> thread = GetMTAThread();
+ MOZ_ASSERT(thread);
+ }
+
template <typename FuncT>
EnsureMTA(const FuncT& aClosure)
{
MOZ_ASSERT(NS_IsMainThread());
if (IsCurrentThreadMTA()) {
// We're already on the MTA, we can run aClosure directly
aClosure();
return;