mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1160298: Modify TaskFactory::NewTask to support variadic templates; r=gfritzsche
This commit is contained in:
parent
ffb6e08be2
commit
a5f6f375fc
@ -7,6 +7,8 @@
|
||||
|
||||
#include <base/task.h>
|
||||
|
||||
#include "mozilla/Move.h"
|
||||
|
||||
/*
|
||||
* This is based on the ScopedRunnableMethodFactory from ipc/chromium/src/base/task.h
|
||||
* Chromium's factories assert if tasks are created and run on different threads,
|
||||
@ -27,7 +29,12 @@ private:
|
||||
class TaskWrapper : public TaskType
|
||||
{
|
||||
public:
|
||||
explicit TaskWrapper(RevocableStore* store) : revocable_(store) { }
|
||||
template<typename... Args>
|
||||
explicit TaskWrapper(RevocableStore* store, Args&&... args)
|
||||
: TaskType(mozilla::Forward<Args>(args)...)
|
||||
, revocable_(store)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Run() {
|
||||
if (!revocable_.revoked())
|
||||
@ -41,11 +48,11 @@ private:
|
||||
public:
|
||||
explicit TaskFactory(T* object) : object_(object) { }
|
||||
|
||||
template <class TaskParamType>
|
||||
inline TaskParamType* NewTask()
|
||||
template <typename TaskParamType, typename... Args>
|
||||
inline TaskParamType* NewTask(Args&&... args)
|
||||
{
|
||||
typedef TaskWrapper<TaskParamType> TaskWrapper;
|
||||
TaskWrapper* task = new TaskWrapper(this);
|
||||
TaskWrapper* task = new TaskWrapper(this, mozilla::Forward<Args>(args)...);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user