"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "netwerk/cache2/CacheIOThread.cpp" between
seamonkey-2.53.8.source.tar.xz and seamonkey-2.53.8.1.source.tar.xz

About: SeaMonkey is an all-in-one internet application suite. Using much of the Mozilla source code it contains a Web-browser, email & newsgroup and feed client, IRC chat, and an included HTML editor.

CacheIOThread.cpp  (seamonkey-2.53.8.source.tar.xz):CacheIOThread.cpp  (seamonkey-2.53.8.1.source.tar.xz)
skipping to change at line 223 skipping to change at line 223
nsresult CacheIOThread::Init() nsresult CacheIOThread::Init()
{ {
{ {
MonitorAutoLock lock(mMonitor); MonitorAutoLock lock(mMonitor);
// Yeah, there is not a thread yet, but we want to make sure // Yeah, there is not a thread yet, but we want to make sure
// the sequencing is correct. // the sequencing is correct.
mBlockingIOWatcher = MakeUnique<detail::BlockingIOWatcher>(); mBlockingIOWatcher = MakeUnique<detail::BlockingIOWatcher>();
} }
mThread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, this, // Increase the reference count while spawning a new thread.
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, // If PR_CreateThread succeeds, we will forget this reference and the thread
PR_JOINABLE_THREAD, 128 * 1024); // will be responsible to release it when it completes.
RefPtr<CacheIOThread> self = this;
mThread =
PR_CreateThread(PR_USER_THREAD, ThreadFunc, this, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 128 * 1024);
if (!mThread) { if (!mThread) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
// IMPORTANT: The thread now owns this reference, so it's important that we
// leak it here, otherwise we'll end up with a bad refcount.
// See the dont_AddRef in ThreadFunc().
Unused << self.forget().take();
return NS_OK; return NS_OK;
} }
nsresult CacheIOThread::Dispatch(nsIRunnable* aRunnable, uint32_t aLevel) nsresult CacheIOThread::Dispatch(nsIRunnable* aRunnable, uint32_t aLevel)
{ {
return Dispatch(do_AddRef(aRunnable), aLevel); return Dispatch(do_AddRef(aRunnable), aLevel);
} }
nsresult CacheIOThread::Dispatch(already_AddRefed<nsIRunnable> aRunnable, nsresult CacheIOThread::Dispatch(already_AddRefed<nsIRunnable> aRunnable,
uint32_t aLevel) uint32_t aLevel)
skipping to change at line 399 skipping to change at line 408
} }
// static // static
void CacheIOThread::ThreadFunc(void* aClosure) void CacheIOThread::ThreadFunc(void* aClosure)
{ {
// XXXmstange We'd like to register this thread with the profiler, but doing // XXXmstange We'd like to register this thread with the profiler, but doing
// so causes leaks, see bug 1323100. // so causes leaks, see bug 1323100.
NS_SetCurrentThreadName("Cache2 I/O"); NS_SetCurrentThreadName("Cache2 I/O");
mozilla::IOInterposer::RegisterCurrentThread(); mozilla::IOInterposer::RegisterCurrentThread();
CacheIOThread* thread = static_cast<CacheIOThread*>(aClosure); // We hold on to this reference for the duration of the thread.
RefPtr<CacheIOThread> thread =
dont_AddRef(static_cast<CacheIOThread*>(aClosure));
thread->ThreadFunc(); thread->ThreadFunc();
mozilla::IOInterposer::UnregisterCurrentThread(); mozilla::IOInterposer::UnregisterCurrentThread();
} }
void CacheIOThread::ThreadFunc() void CacheIOThread::ThreadFunc()
{ {
nsCOMPtr<nsIThreadInternal> threadInternal; nsCOMPtr<nsIThreadInternal> threadInternal;
{ {
MonitorAutoLock lock(mMonitor); MonitorAutoLock lock(mMonitor);
 End of changes. 3 change blocks. 
4 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)