sbRunnableMethod1< ClassType, ReturnType, Arg1Type > Class Template Reference

#include <sbThreadUtils.h>

Inheritance diagram for sbRunnableMethod1< ClassType, ReturnType, Arg1Type >:
[legend]
Collaboration diagram for sbRunnableMethod1< ClassType, ReturnType, Arg1Type >:
[legend]

Public Types

typedef sbRunnableMethod1
< ClassType, ReturnType,
Arg1Type > 
SelfType
 
typedef ReturnType(ClassType::* MethodType )(Arg1Type aArg1Value)
 

Public Member Functions

NS_IMETHOD Run ()
 
ReturnType GetReturnValue ()
 

Static Public Member Functions

static nsresult New (SelfType **aRunnable, ClassType *aObject, MethodType aMethod, ReturnType aFailureReturnValue, Arg1Type aArg1Value)
 
static ReturnType InvokeOnMainThread (ClassType *aObject, MethodType aMethod, ReturnType aFailureReturnValue, Arg1Type aArg1Value)
 
static ReturnType InvokeOnThread (ClassType *aObject, MethodType aMethod, ReturnType aFailureReturnValue, Arg1Type aArg1Value, nsIEventTarget *aThread)
 
static nsresult InvokeOnMainThreadAsync (ClassType *aObject, MethodType aMethod, ReturnType aFailureReturnValue, Arg1Type aArg1Value)
 
static nsresult InvokeOnThreadAsync (ClassType *aObject, MethodType aMethod, ReturnType aFailureReturnValue, Arg1Type aArg1Value, nsIEventTarget *aThread)
 

Protected Member Functions

 sbRunnableMethod1 (ClassType *aObject, MethodType aMethod, ReturnType aFailureReturnValue, Arg1Type aArg1Value)
 
virtual ~sbRunnableMethod1 ()
 
nsresult Initialize ()
 

Protected Attributes

PRLock * mLock
 
nsRefPtr< ClassType > mObject
 
MethodType mMethod
 
ReturnType mReturnValue
 
ReturnType mFailureReturnValue
 
Arg1Type mArg1Value
 

Detailed Description

template<class ClassType, typename ReturnType, typename Arg1Type>
class sbRunnableMethod1< ClassType, ReturnType, Arg1Type >

This class provides an nsIRunnable interface, like nsRunnableMethod, that invokes a provided class method from nsIRunnable::Run. This class passes a single argument to the method and collects the return value. The method return value may be read using GetReturnValue. If any error occurs attempting to invoke the method, a failure value may be specified to be used as the return value.

XXXeps need specialization for methods returning void.

Definition at line 74 of file sbThreadUtils.h.

Member Typedef Documentation

template<class ClassType , typename ReturnType , typename Arg1Type >
typedef ReturnType(ClassType::* sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::MethodType)(Arg1Type aArg1Value)

Definition at line 90 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
typedef sbRunnableMethod1<ClassType, ReturnType, Arg1Type> sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::SelfType

Definition at line 89 of file sbThreadUtils.h.

Constructor & Destructor Documentation

template<class ClassType , typename ReturnType , typename Arg1Type >
sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::sbRunnableMethod1 ( ClassType *  aObject,
MethodType  aMethod,
ReturnType  aFailureReturnValue,
Arg1Type  aArg1Value 
)
inlineprotected

Construct a Songbird runnable method for the object specified by aObject. Call the object method specified by aMethod with the argument specified by aArg1Value. Use the value specified by aFailureReturnValue as the failure return value.

Parameters
aObjectObject for which to create a Songbird runnable method.
aMethodMethod to be invoked.
aFailureReturnValueValue to which to set runnable method return value on internal failures.
aArg1ValueValue of first method argument.

Definition at line 354 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
virtual sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::~sbRunnableMethod1 ( )
inlineprotectedvirtual

Dispose of the Songbird runnable method.

Definition at line 372 of file sbThreadUtils.h.

Member Function Documentation

template<class ClassType , typename ReturnType , typename Arg1Type >
ReturnType sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::GetReturnValue ( )
inline

Get the runnable method return value.

Returns
Runnable method return value.

Definition at line 324 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
nsresult sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::Initialize ( )
inlineprotected

Initialize the Songbird runnable method.

Definition at line 384 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
static ReturnType sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::InvokeOnMainThread ( ClassType *  aObject,
MethodType  aMethod,
ReturnType  aFailureReturnValue,
Arg1Type  aArg1Value 
)
inlinestatic

Invoke the method specified by aMethod of the object specified by aObject on the main thread. Invoke the method with the argument specified by aArg1Value. Return the value returned by the invoked method. If any error occurs, return aFailureReturnValue.

Parameters
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aFailureReturnValueValue to return on failure.
aArg1ValueValue of first method argument.
Returns
Value returned by invoked method or aFailureReturnValue on failure.

Definition at line 180 of file sbThreadUtils.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ClassType , typename ReturnType , typename Arg1Type >
static nsresult sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::InvokeOnMainThreadAsync ( ClassType *  aObject,
MethodType  aMethod,
ReturnType  aFailureReturnValue,
Arg1Type  aArg1Value 
)
inlinestatic

Asynchronously, invoke the method specified by aMethod of the object specified by aObject on the main thread. Invoke the method with the argument specified by aArg1Value. Use the value specified by aFailureReturnValue as the runnable method failure return value. XXXeps the return value is only needed to properly create the object.

Parameters
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aFailureReturnValueValue to return on failure.
aArg1ValueValue of first method argument.

Definition at line 257 of file sbThreadUtils.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ClassType , typename ReturnType , typename Arg1Type >
static ReturnType sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::InvokeOnThread ( ClassType *  aObject,
MethodType  aMethod,
ReturnType  aFailureReturnValue,
Arg1Type  aArg1Value,
nsIEventTarget *  aThread 
)
inlinestatic

Invoke the method specified by aMethod of the object specified by aObject on the supplied thread. Invoke the method with the argument specified by aArg1Value. Return the value returned by the invoked method. If any error occurs, return aFailureReturnValue.

Parameters
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aFailureReturnValueValue to return on failure.
aArg1ValueValue of first method argument.
aThreadThread to run on.
Returns
Value returned by invoked method or aFailureReturnValue on failure.

Definition at line 219 of file sbThreadUtils.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ClassType , typename ReturnType , typename Arg1Type >
static nsresult sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::InvokeOnThreadAsync ( ClassType *  aObject,
MethodType  aMethod,
ReturnType  aFailureReturnValue,
Arg1Type  aArg1Value,
nsIEventTarget *  aThread 
)
inlinestatic

Asynchronously, invoke the method specified by aMethod of the object specified by aObject on the supplied thread. Invoke the method with the argument specified by aArg1Value. Use the value specified by aFailureReturnValue as the runnable method failure return value. XXXeps the return value is only needed to properly create the object.

Parameters
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aFailureReturnValueValue to return on failure.
aArg1ValueValue of first method argument.
aThreadThread to run on.

Definition at line 294 of file sbThreadUtils.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class ClassType , typename ReturnType , typename Arg1Type >
static nsresult sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::New ( SelfType **  aRunnable,
ClassType *  aObject,
MethodType  aMethod,
ReturnType  aFailureReturnValue,
Arg1Type  aArg1Value 
)
inlinestatic

Create and initialize a Songbird runnable method for the object specified by aObject. Call the object method specified by aMethod with the argument specified by aArg1Value. Use the value specified by aFailureReturnValue as the failure return value. Return the new Songbird runnable method in aRunnable.

Parameters
aRunnableReturned created Songbird runnable method.
aObjectObject for which to create a Songbird runnable method.
aMethodMethod to be invoked.
aFailureReturnValueValue to which to set runnable method return value on internal failures.
aArg1ValueValue of first method argument.

Definition at line 133 of file sbThreadUtils.h.

Here is the caller graph for this function:

template<class ClassType , typename ReturnType , typename Arg1Type >
NS_IMETHOD sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::Run ( )
inline

nsIRunnable run method. Invoke the Songbird runnable method.

Definition at line 97 of file sbThreadUtils.h.

Member Data Documentation

template<class ClassType , typename ReturnType , typename Arg1Type >
Arg1Type sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::mArg1Value
protected

Definition at line 408 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
ReturnType sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::mFailureReturnValue
protected

Definition at line 407 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
PRLock* sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::mLock
protected

Definition at line 403 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
MethodType sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::mMethod
protected

Definition at line 405 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
nsRefPtr<ClassType> sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::mObject
protected

Definition at line 404 of file sbThreadUtils.h.

template<class ClassType , typename ReturnType , typename Arg1Type >
ReturnType sbRunnableMethod1< ClassType, ReturnType, Arg1Type >::mReturnValue
protected

Definition at line 406 of file sbThreadUtils.h.


The documentation for this class was generated from the following file: