diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 02:17:23 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 02:17:23 +0000 |
commit | c56428f24b67efa6a2eff77a709b7b6489403617 (patch) | |
tree | ab1966b7a60fe6d97062480d501e16fcbc00837a /base/task.h | |
parent | 6c23230f2e2b345a7fafb4caf814e07b8228cae7 (diff) | |
download | chromium_src-c56428f24b67efa6a2eff77a709b7b6489403617.zip chromium_src-c56428f24b67efa6a2eff77a709b7b6489403617.tar.gz chromium_src-c56428f24b67efa6a2eff77a709b7b6489403617.tar.bz2 |
Add DISABLE_RUNNABLE_METHOD_REFCOUNT to make disabling refcounts in RunnableMethods easier.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2830006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49887 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/task.h')
-rw-r--r-- | base/task.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/base/task.h b/base/task.h index 454878a..1425546 100644 --- a/base/task.h +++ b/base/task.h @@ -212,6 +212,9 @@ class ReleaseTask : public CancelableTask { // define other lifetime management. For example, if the callee is known to // live longer than the RunnableMethod object, then a RunnableMethodTraits // struct could be defined with empty RetainCallee and ReleaseCallee methods. +// +// The DISABLE_RUNNABLE_METHOD_REFCOUNT macro is provided as a convenient way +// for declaring a RunnableMethodTraits that disables refcounting. template <class T> struct RunnableMethodTraits { @@ -251,6 +254,30 @@ struct RunnableMethodTraits { #endif }; +// Convenience macro for declaring a RunnableMethodTraits that disables +// refcounting of a class. This is useful if you know that the callee +// will outlive the RunnableMethod object and thus do not need the ref counts. +// +// The invocation of DISABLE_RUNNABLE_METHOD_REFCOUNT should be done at the +// global namespace scope. Example: +// +// namespace foo { +// class Bar { +// ... +// }; +// } // namespace foo +// +// DISABLE_RUNNABLE_METHOD_REFCOUNT(foo::Bar) +// +// This is different from DISALLOW_COPY_AND_ASSIGN which is declared inside the +// class. +#define DISABLE_RUNNABLE_METHOD_REFCOUNT(TypeName) \ + template <> \ + struct RunnableMethodTraits<TypeName> { \ + void RetainCallee(TypeName* manager) {} \ + void ReleaseCallee(TypeName* manager) {} \ + } + // RunnableMethod and RunnableFunction ----------------------------------------- // // Runnable methods are a type of task that call a function on an object when |