diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-22 23:09:21 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-22 23:09:21 +0000 |
commit | 503631cfa06aaae686f2e9a6f55ebc1859e8dab3 (patch) | |
tree | 8bc3a1d62749c65585db050b0926add085485436 /base/task.h | |
parent | 4d40fd494fc3142ded2eddc2a1becaa7a1584d06 (diff) | |
download | chromium_src-503631cfa06aaae686f2e9a6f55ebc1859e8dab3.zip chromium_src-503631cfa06aaae686f2e9a6f55ebc1859e8dab3.tar.gz chromium_src-503631cfa06aaae686f2e9a6f55ebc1859e8dab3.tar.bz2 |
Create a thread-safe observer list. Will be used
by SystemMonitor.
Right now the class requires that Observers be RefCounted<>. This is because we invoke tasks via NewRunnableMethod for them. However, because we manually track lifecycle via AddObserver/RemoveObserver, we could override the RunnableMethodTraits to not require RefCounted<>. This would have the advantage that callers do not need to make all Observers be RefCounted, but makes it more critical that observers not forget to call RemoveObserver().
Review URL: http://codereview.chromium.org/7353
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3787 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/task.h')
-rw-r--r-- | base/task.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/base/task.h b/base/task.h index 8db4560..9d4e6e2 100644 --- a/base/task.h +++ b/base/task.h @@ -625,5 +625,19 @@ typename Callback5<Arg1, Arg2, Arg3, Arg4, Arg5>::Type* NewCallback( Tuple5<Arg1, Arg2, Arg3, Arg4, Arg5> >(object, method); } +// An UnboundMethod is a wrapper for a method where the actual object is +// provided at Run dispatch time. +template <class T, class Method, class Params> +class UnboundMethod { + public: + UnboundMethod(Method m, Params p) : m_(m), p_(p) {} + void Run(T* obj) const { + DispatchToMethod(obj, m_, p_); + } + private: + Method m_; + Params p_; +}; + #endif // BASE_TASK_H__ |