sbThreadUtils.h File Reference

Songbird Thread Utilities Definitions. More...

#include <mozilla/Monitor.h>
#include <nsAutoLock.h>
#include <nsAutoPtr.h>
#include <nsIThreadPool.h>
#include <nsThreadUtils.h>
Include dependency graph for sbThreadUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  sbRunnableMethod1< ClassType, ReturnType, Arg1Type >
 
class  sbRunnableMethod2< ClassType, ReturnType, Arg1Type, Arg2Type >
 
class  sbRunnable
 
class  sbRunnable_< ResultType >
 
class  sbRunnable_< void >
 
class  sbRunnableMethod_< ResultType, TargetType, MethodType >
 
class  sbRunnableMethod1_< ResultType, TargetType, Param1Type, Arg1Type, MethodType >
 
class  sbRunnableMethod2_< ResultType, TargetType, Param1Type, Param2Type, Arg1Type, Arg2Type, MethodType >
 
class  sbRunnableMethod3_< ResultType, TargetType, Param1Type, Param2Type, Param3Type, Arg1Type, Arg2Type, Arg3Type, MethodType >
 
class  sbRunnableMethod4_< ResultType, TargetType, Param1Type, Param2Type, Param3Type, Param4Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, MethodType >
 
class  sbRunnableMethod5_< ResultType, TargetType, Param1Type, Param2Type, Param3Type, Param4Type, Param5Type, Arg1Type, Arg2Type, Arg3Type, Arg4Type, Arg5Type, MethodType >
 

Macros

#define SB_INVOKE_ON_MAIN_THREAD1(aClassType,aObject,aMethod,aReturnType,aFailureReturnValue,aArg1Type,aArg1Value)
 
#define SB_INVOKE_ON_MAIN_THREAD2(aClassType,aObject,aMethod,aReturnType,aFailureReturnValue,aArg1Type,aArg1Value,aArg2Type,aArg2Value)
 
#define SB_INVOKE_ON_MAIN_THREAD_ASYNC1(aClassType,aObject,aMethod,aReturnType,aFailureReturnValue,aArg1Type,aArg1Value)
 
#define SB_INVOKE_ON_MAIN_THREAD_ASYNC2(aClassType,aObject,aMethod,aReturnType,aFailureReturnValue,aArg1Type,aArg1Value,aArg2Type,aArg2Value)
 

Functions

template<class T , class MT , class RT , class A1 >
RT sbInvokeOnMainThread1 (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1)
 
template<class T , class MT , class RT , class A1 , class TH >
RT sbInvokeOnThread1 (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1, TH aThread)
 
template<class T , class MT , class RT , class A1 >
nsresult sbInvokeOnMainThread1Async (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1)
 
template<class T , class MT , class RT , class A1 , class TH >
nsresult sbInvokeOnThread1Async (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1, TH aThread)
 
template<class T , class MT , class RT , class A1 , class A2 >
RT sbInvokeOnMainThread2 (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1, A2 aArg2)
 
template<class T , class MT , class RT , class A1 , class A2 , class TH >
RT sbInvokeOnThread2 (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1, A2 aArg2, TH aThread)
 
template<class T , class MT , class RT , class A1 , class A2 >
nsresult sbInvokeOnMainThread2Async (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1, A2 aArg2)
 
template<class T , class MT , class RT , class A1 , class A2 , class TH >
nsresult sbInvokeOnThread2Async (T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1, A2 aArg2, TH aThread)
 
PRBool SB_IsMainThread (nsIThreadManager *aThreadManager=nsnull)
 

Detailed Description

Songbird Thread Utilities Definitions.

Definition in file sbThreadUtils.h.

Macro Definition Documentation

#define SB_INVOKE_ON_MAIN_THREAD1 (   aClassType,
  aObject,
  aMethod,
  aReturnType,
  aFailureReturnValue,
  aArg1Type,
  aArg1Value 
)
Value:
&aClassType::aMethod, \
aFailureReturnValue, \
aArg1Value)

From the main thread, invoke the method specified by aMethod on the object specified by aObject of the type specified by aClassType. Return the method's return value of type aReturnType. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1Value of type specified by aArg1Type.

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

Definition at line 1252 of file sbThreadUtils.h.

#define SB_INVOKE_ON_MAIN_THREAD2 (   aClassType,
  aObject,
  aMethod,
  aReturnType,
  aFailureReturnValue,
  aArg1Type,
  aArg1Value,
  aArg2Type,
  aArg2Value 
)
Value:
&aClassType::aMethod, \
aFailureReturnValue, \
aArg1Value, \
aArg2Value)

Definition at line 1378 of file sbThreadUtils.h.

#define SB_INVOKE_ON_MAIN_THREAD_ASYNC1 (   aClassType,
  aObject,
  aMethod,
  aReturnType,
  aFailureReturnValue,
  aArg1Type,
  aArg1Value 
)
Value:
&aClassType::aMethod, \
aFailureReturnValue, \
aArg1Value)

From the main thread, asynchronously invoke the method specified by aMethod on the object specified by aObject of the type specified by aClassType. Pass to the method the argument value specified by aArg1Value of type specified by aArg1Type. 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
aClassTypeType of method class.
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aReturnTypeType of method return value.
aFailureReturnValueValue to return on failure.
aArg1TypeType of first method argument.
aArg1ValueValue of first method argument.
Returns
Value returned by invoked method or aFailureReturnValue on failure.

Definition at line 1541 of file sbThreadUtils.h.

#define SB_INVOKE_ON_MAIN_THREAD_ASYNC2 (   aClassType,
  aObject,
  aMethod,
  aReturnType,
  aFailureReturnValue,
  aArg1Type,
  aArg1Value,
  aArg2Type,
  aArg2Value 
)
Value:
&aClassType::aMethod, \
aFailureReturnValue, \
aArg1Value, \
aArg2Value)

Definition at line 1554 of file sbThreadUtils.h.

Function Documentation

PRBool SB_IsMainThread ( nsIThreadManager *  aThreadManager)

Check if the current thread is the main thread and return true if so. Use the thread manager object specified by aThreadManager if provided. This function can be used during XPCOM shutdown if aThreadManager is provided.

Parameters
aThreadManagerOptional thread manager. Defaults to null.
Returns
PR_TRUE Current thread is main thread.

Definition at line 71 of file sbThreadUtils.cpp.

Here is the caller graph for this function:

template<class T , class MT , class RT , class A1 >
RT sbInvokeOnMainThread1 ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1 
)
inline

From the main thread, invoke the method specified by aMethod on the object specified by aObject. Return the method's return value. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

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

Definition at line 1281 of file sbThreadUtils.h.

Here is the call graph for this function:

template<class T , class MT , class RT , class A1 >
nsresult sbInvokeOnMainThread1Async ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1 
)
inline

From the main thread, invoke asynchronously the method specified by aMethod on the object specified by aObject. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

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

Definition at line 1337 of file sbThreadUtils.h.

Here is the call graph for this function:

template<class T , class MT , class RT , class A1 , class A2 >
RT sbInvokeOnMainThread2 ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1,
A2  aArg2 
)
inline

From the main thread, invoke the method specified by aMethod on the object specified by aObject. Return the method's return value. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

Parameters
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aFailureReturnValueValue to return on failure.
aArg1Value of the first argument.
aArg2Value of the second argument
Returns
aFailureReturnValue on failure.

Definition at line 1410 of file sbThreadUtils.h.

Here is the call graph for this function:

template<class T , class MT , class RT , class A1 , class A2 >
nsresult sbInvokeOnMainThread2Async ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1,
A2  aArg2 
)
inline

From the main thread, invoke asynchronously the method specified by aMethod on the object specified by aObject. Return the method's return value. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

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

Definition at line 1473 of file sbThreadUtils.h.

Here is the call graph for this function:

template<class T , class MT , class RT , class A1 , class TH >
RT sbInvokeOnThread1 ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1,
TH  aThread 
)
inline

From the supplied thread, invoke the method specified by aMethod on the object specified by aObject. Return the method's return value. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

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

Definition at line 1309 of file sbThreadUtils.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T , class MT , class RT , class A1 , class TH >
nsresult sbInvokeOnThread1Async ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1,
TH  aThread 
)
inline

From the supplied thread, invoke asynchronously the method specified by aMethod on the object specified by aObject. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

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

Definition at line 1365 of file sbThreadUtils.h.

Here is the call graph for this function:

template<class T , class MT , class RT , class A1 , class A2 , class TH >
RT sbInvokeOnThread2 ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1,
A2  aArg2,
TH  aThread 
)
inline

From the supplied thread, invoke the method specified by aMethod on the object specified by aObject. Return the method's return value. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

Parameters
aObjectObject for which to invoke method.
aMethodMethod to invoke.
aFailureReturnValueValue to return on failure.
aArg1Value of the first argument.
aArg2Value of the second argument
aThreadThread to run on.
Returns
aFailureReturnValue on failure.

Definition at line 1441 of file sbThreadUtils.h.

Here is the call graph for this function:

template<class T , class MT , class RT , class A1 , class A2 , class TH >
nsresult sbInvokeOnThread2Async ( T &  aObject,
MT  aMethod,
RT  aFailureReturnValue,
A1  aArg1,
A2  aArg2,
TH  aThread 
)
inline

From the supplied thread, invoke asynchronously the method specified by aMethod on the object specified by aObject. Return the method's return value. On any error, return the value specified by aFailureReturnValue. Pass to the method the argument value specified by aArg1.

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

Definition at line 1505 of file sbThreadUtils.h.

Here is the call graph for this function: