Back out cset 35cae02f1552 (bug 1152753) because it introduces a footgun. r=me

This commit is contained in:
Kartikaya Gupta 2015-04-10 12:13:55 -04:00
parent 613f766046
commit 7ac4ed1b3b

View File

@ -19,7 +19,6 @@
#include "nsAutoPtr.h"
#include "mozilla/Atomics.h"
#include "mozilla/Likely.h"
#include "mozilla/TypeTraits.h"
//-----------------------------------------------------------------------------
// These methods are alternatives to the methods on nsIThreadManager, provided
@ -239,33 +238,6 @@ protected:
virtual ~nsCancelableRunnable() {}
};
// An event that can be used to call a C++11 functions or function objects,
// including lambdas. The function must have no required arguments, and must
// return void.
template<typename Function>
class nsRunnableFunction : public nsRunnable
{
public:
explicit nsRunnableFunction(const Function& aFunction)
: mFunction(aFunction)
{ }
NS_IMETHOD Run() {
static_assert(mozilla::IsVoid<decltype(mFunction())>::value,
"The lambda must return void!");
mFunction();
return NS_OK;
}
private:
Function mFunction;
};
template<typename Function>
nsRunnableFunction<Function>* NS_NewRunnableFunction(const Function& aFunction)
{
return new nsRunnableFunction<Function>(aFunction);
}
// An event that can be used to call a method on a class. The class type must
// support reference counting. This event supports Revoke for use
// with nsRevocableEventPtr.