Created
November 9, 2009 15:36
-
-
Save kevinw/230036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef void MainThreadFunction(void*); | |
void callOnMainThread(MainThreadFunction*, void* context); | |
template <typename T> | |
static void deref(void* obj) | |
{ | |
static_cast<T*>(obj)->deref(); | |
} | |
template <typename T> | |
static void derefOnMainThread(RefPtr<T>& ref) | |
{ | |
callOnMainThread(deref, ref.release().releaseRef()); | |
} | |
void foo() { | |
RefPtr<Document> m_document = /*blah*/; | |
derefOnMainThread(m_document); | |
} | |
/* | |
Database.cpp | |
.\storage\Database.cpp(183) : error C2664: 'WTF::callOnMainThread' : cannot convert parameter 1 from 'void (__cdecl *)(void *)' to 'WTF | |
::MainThreadFunction (__cdecl *)' | |
None of the functions with this name in scope match the target type | |
.\storage\Database.cpp(211) : see reference to function template instantiation 'void WebCore::derefOnMainThread<WebCore::Docume | |
nt>(WTF::RefPtr<T> &)' being compiled | |
with | |
[ | |
T=WebCore::Document | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment