[Webkit-unassigned] [Bug 43135] Decouple FileThread from FileStream to support generic file-related async tasks

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 28 15:01:16 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=43135


Jian Li <jianli at chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #62860|review?                     |review-
               Flag|                            |




--- Comment #2 from Jian Li <jianli at chromium.org>  2010-07-28 15:01:16 PST ---
(From update of attachment 62860)
It is a good idea to support generic file related async tasks. However, I am thinking if it is possible to make current FileThreadTask support calling any class methods asynchronously. How about something like the following:

// FileThread.h
    ...

    class Task : public Noncopyable {
    public:
        virtual ~Task() { }
        virtual void performTask() = 0;
        void* instance() const { return m_instance; }
    protected:
        Task(void* instance) : m_instance(instance) { }
        void* m_instance;
    };

    void postTask(PassOwnPtr<Task> task);
    void unscheduleTasks(const void* instance);

// FileThreadTask.h

...

template<typename R, typename T>
class FileThreadTask0 : public FileThread::Task {
public:
    typedef R (T::*Method)();
    typedef FileThreadTask0<R, T> FileThreadTask;

    static PassOwnPtr<FileThreadTask> create(T* instance, Method method)
    {
        return new FileThreadTask(instance, method);
    }

private:
    FileThreadTask0(T* instance, Method method)
        : FileThread::Task(instance)
        , m_method(method)
    {
    }

    virtual void performTask()
    {
        (*reinterpret_cast<T*>(instance()).*m_method)();
    }

private:
    Method m_method;
};

...

template<typename R, typename T>
PassOwnPtr<FileThread::Task> createFileThreadTask(
    T* const callee,
    R (T::*method)())
{
    return FileThreadTask0<R, T>::create(
        callee,
        method);
}

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list