NS_IMETHODIMP LazyIdleThread::Dispatch(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags) { ASSERT_OWNING_THREAD(); nsCOMPtr<nsIRunnable> event(aEvent); // avoid leaks // LazyIdleThread can't always support synchronous dispatch currently. if (NS_WARN_IF(aFlags != NS_DISPATCH_NORMAL)) { return NS_ERROR_NOT_IMPLEMENTED; } if (NS_WARN_IF(mShutdown)) { return NS_ERROR_UNEXPECTED; } // If our thread is shutting down then we can't actually dispatch right now. // Queue this runnable for later. if (UseRunnableQueue()) { mQueuedRunnables->AppendElement(event); return NS_OK; } nsresult rv = EnsureThread(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } PreDispatch(); return mThread->Dispatch(event.forget(), aFlags); }
NS_IMETHODIMP LazyIdleThread::Dispatch(nsIRunnable* aEvent, uint32_t aFlags) { ASSERT_OWNING_THREAD(); // LazyIdleThread can't always support synchronous dispatch currently. if (NS_WARN_IF(aFlags != NS_DISPATCH_NORMAL)) return NS_ERROR_NOT_IMPLEMENTED; // If our thread is shutting down then we can't actually dispatch right now. // Queue this runnable for later. if (UseRunnableQueue()) { mQueuedRunnables->AppendElement(aEvent); return NS_OK; } nsresult rv = EnsureThread(); if (NS_WARN_IF(NS_FAILED(rv))) return rv; PreDispatch(); return mThread->Dispatch(aEvent, aFlags); }