Bug 1056356 - Allow calling NewRunnableMethod() with a const pointer to the callee object. r=froydnj

--HG--
extra : rebase_source : 2cd101c22d0992acedccf50e7f5880a268cef199
This commit is contained in:
Botond Ballo 2015-07-29 19:51:36 -04:00
parent 1ad5e05028
commit a7263cd695

View File

@ -267,6 +267,19 @@ struct RunnableMethodTraits {
}
};
// This allows using the NewRunnableMethod() functions with a const pointer
// to the callee object. See the similar support in nsRefPtr for a rationale
// of why this is reasonable.
template <class T>
struct RunnableMethodTraits<const T> {
static void RetainCallee(const T* obj) {
const_cast<T*>(obj)->AddRef();
}
static void ReleaseCallee(const T* obj) {
const_cast<T*>(obj)->Release();
}
};
// RunnableMethod and RunnableFunction -----------------------------------------
//
// Runnable methods are a type of task that call a function on an object when