Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1444)

Unified Diff: Source/platform/audio/HRTFDatabaseLoader.cpp

Issue 711323002: Oilpan: Don't destruct HRTFDatabaseLoader::m_thread during a sweeping phase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/audio/HRTFDatabaseLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/audio/HRTFDatabaseLoader.cpp
diff --git a/Source/platform/audio/HRTFDatabaseLoader.cpp b/Source/platform/audio/HRTFDatabaseLoader.cpp
index 79f1fc2c544c4e36485c7b5474a81d107b42b4e6..332952bb66cbc2fa87c771cb22f5600d934e9533 100644
--- a/Source/platform/audio/HRTFDatabaseLoader.cpp
+++ b/Source/platform/audio/HRTFDatabaseLoader.cpp
@@ -33,6 +33,7 @@
#include "platform/audio/HRTFDatabaseLoader.h"
#include "platform/Task.h"
+#include "platform/TaskSynchronizer.h"
#include "public/platform/Platform.h"
#include "wtf/MainThread.h"
@@ -71,10 +72,10 @@ HRTFDatabaseLoader::HRTFDatabaseLoader(float sampleRate)
HRTFDatabaseLoader::~HRTFDatabaseLoader()
{
ASSERT(isMainThread());
- waitForLoaderThreadCompletion();
+ ASSERT(!m_thread);
}
-void HRTFDatabaseLoader::load()
+void HRTFDatabaseLoader::loadTask()
{
ASSERT(!isMainThread());
m_thread->attachGC();
@@ -98,7 +99,7 @@ void HRTFDatabaseLoader::loadAsynchronously()
if (!m_hrtfDatabase && !m_thread) {
// Start the asynchronous database loading process.
m_thread = WebThreadSupportingGC::create("HRTF database loader");
- m_thread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader::load, this)));
+ m_thread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader::loadTask, this)));
}
}
@@ -108,8 +109,21 @@ bool HRTFDatabaseLoader::isLoaded()
return m_hrtfDatabase;
}
+// This cleanup task is needed just to make sure that the loader thread finishes
+// the load task and thus the loader thread doesn't touch m_thread any more.
+void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync)
+{
+ sync->taskCompleted();
+}
+
void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
{
+ if (!m_thread)
+ return;
+
+ TaskSynchronizer sync;
+ m_thread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader::cleanupTask, this, &sync)));
+ sync.waitForTaskCompletion();
m_thread.clear();
}
« no previous file with comments | « Source/platform/audio/HRTFDatabaseLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698