Skip to content

Instantly share code, notes, and snippets.

@kevinw
Created November 9, 2009 15:36
Show Gist options
  • Save kevinw/230036 to your computer and use it in GitHub Desktop.
Save kevinw/230036 to your computer and use it in GitHub Desktop.
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