Bug 1323100 - Make NS_NewNamedThread use nsThreadManager::NewNamedThread. r=froydnj

MozReview-Commit-ID: 7e6l1A89he9

--HG--
extra : rebase_source : 376ed44481256b26d89b0c638c67a778b3a096a8
This commit is contained in:
Markus Stange 2016-12-20 14:18:22 +01:00
Родитель 8924022f9d
Коммит 657be232e0
2 изменённых файлов: 15 добавлений и 23 удалений

Просмотреть файл

@ -95,13 +95,16 @@ IncrementalRunnable::SetDeadline(TimeStamp aDeadline)
//-----------------------------------------------------------------------------
nsresult
NS_NewThread(nsIThread** aResult, nsIRunnable* aEvent, uint32_t aStackSize)
NS_NewNamedThread(const nsACString& aName,
nsIThread** aResult,
nsIRunnable* aEvent,
uint32_t aStackSize)
{
nsCOMPtr<nsIThread> thread;
#ifdef MOZILLA_INTERNAL_API
nsresult rv =
nsThreadManager::get().nsThreadManager::NewThread(0, aStackSize,
getter_AddRefs(thread));
nsThreadManager::get().nsThreadManager::NewNamedThread(aName, aStackSize,
getter_AddRefs(thread));
#else
nsresult rv;
nsCOMPtr<nsIThreadManager> mgr =
@ -110,7 +113,7 @@ NS_NewThread(nsIThread** aResult, nsIRunnable* aEvent, uint32_t aStackSize)
return rv;
}
rv = mgr->NewThread(0, aStackSize, getter_AddRefs(thread));
rv = mgr->NewNamedThread(aName, aStackSize, getter_AddRefs(thread));
#endif
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -128,6 +131,12 @@ NS_NewThread(nsIThread** aResult, nsIRunnable* aEvent, uint32_t aStackSize)
return NS_OK;
}
nsresult
NS_NewThread(nsIThread** aResult, nsIRunnable* aEvent, uint32_t aStackSize)
{
return NS_NewNamedThread(NS_LITERAL_CSTRING(""), aResult, aEvent, aStackSize);
}
nsresult
NS_GetCurrentThread(nsIThread** aResult)
{

Просмотреть файл

@ -71,28 +71,11 @@ NS_NewThread(nsIThread** aResult,
/**
* Creates a named thread, otherwise the same as NS_NewThread
*/
inline nsresult
extern nsresult
NS_NewNamedThread(const nsACString& aName,
nsIThread** aResult,
nsIRunnable* aInitialEvent = nullptr,
uint32_t aStackSize = nsIThreadManager::DEFAULT_STACK_SIZE)
{
// Hold a ref while dispatching the initial event to match NS_NewThread()
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewThread(getter_AddRefs(thread), nullptr, aStackSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
NS_SetThreadName(thread, aName);
if (aInitialEvent) {
rv = thread->Dispatch(aInitialEvent, NS_DISPATCH_NORMAL);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Initial event dispatch failed");
}
*aResult = nullptr;
thread.swap(*aResult);
return rv;
}
uint32_t aStackSize = nsIThreadManager::DEFAULT_STACK_SIZE);
template<size_t LEN>
inline nsresult