Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::ActiveMethod< ResultType, void, OwnerType, StarterType > Class Template Reference

#include <ActiveMethod.h>

Public Types

typedef ResultType(OwnerType::* Callback) (void)
 
typedef ActiveResult< ResultType > ActiveResultType
 
typedef ActiveRunnable< ResultType, void, OwnerType > ActiveRunnableType
 

Public Member Functions

 ActiveMethod (OwnerType *pOwner, Callback method)
 
ActiveResultType operator() (void)
 Invokes the ActiveMethod.
 
 ActiveMethod (const ActiveMethod &other)
 
ActiveMethodoperator= (const ActiveMethod &other)
 
void swap (ActiveMethod &other)
 

Private Member Functions

 ActiveMethod ()
 

Private Attributes

OwnerType * _pOwner
 
Callback _method
 

Detailed Description

template<class ResultType, class OwnerType, class StarterType>
class Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >

An active method is a method that, when called, executes in its own thread. ActiveMethod's take exactly one argument and can return a value. To pass more than one argument to the method, use a struct. The following example shows how to add an ActiveMethod to a class:

class ActiveObject
{
public:
    ActiveObject():
        exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
    {
    }

    ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;

protected:
    std::string exampleActiveMethodImpl(const std::string& arg)
    {
        ...
    }
};

And following is an example that shows how to invoke an ActiveMethod.

ActiveObject myActiveObject;
ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
...
result.wait();
std::cout << result.data() << std::endl;

The way an ActiveMethod is started can be changed by passing a StarterType template argument with a corresponding class. The default ActiveStarter starts the method in its own thread, obtained from a thread pool.

For an alternative implementation of StarterType, see ActiveDispatcher.

For methods that do not require an argument or a return value, simply use void.

Definition at line 125 of file ActiveMethod.h.

Member Typedef Documentation

◆ ActiveResultType

template<class ResultType , class OwnerType , class StarterType >
typedef ActiveResult<ResultType> Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::ActiveResultType

Definition at line 168 of file ActiveMethod.h.

◆ ActiveRunnableType

template<class ResultType , class OwnerType , class StarterType >
typedef ActiveRunnable<ResultType, void, OwnerType> Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::ActiveRunnableType

Definition at line 169 of file ActiveMethod.h.

◆ Callback

template<class ResultType , class OwnerType , class StarterType >
typedef ResultType(OwnerType::* Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::Callback) (void)

Definition at line 167 of file ActiveMethod.h.

Constructor & Destructor Documentation

◆ ActiveMethod() [1/3]

template<class ResultType , class OwnerType , class StarterType >
Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::ActiveMethod ( OwnerType * pOwner,
Callback method )
inline

Definition at line 171 of file ActiveMethod.h.

◆ ActiveMethod() [2/3]

template<class ResultType , class OwnerType , class StarterType >
Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::ActiveMethod ( const ActiveMethod< ResultType, void, OwnerType, StarterType > & other)
inline

Definition at line 188 of file ActiveMethod.h.

◆ ActiveMethod() [3/3]

template<class ResultType , class OwnerType , class StarterType >
Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::ActiveMethod ( )
private

Member Function Documentation

◆ operator()()

template<class ResultType , class OwnerType , class StarterType >
ActiveResultType Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::operator() ( void )
inline

Invokes the ActiveMethod.

Definition at line 179 of file ActiveMethod.h.

◆ operator=()

template<class ResultType , class OwnerType , class StarterType >
ActiveMethod & Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::operator= ( const ActiveMethod< ResultType, void, OwnerType, StarterType > & other)
inline

Definition at line 194 of file ActiveMethod.h.

◆ swap()

template<class ResultType , class OwnerType , class StarterType >
void Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::swap ( ActiveMethod< ResultType, void, OwnerType, StarterType > & other)
inline

Definition at line 201 of file ActiveMethod.h.

Member Data Documentation

◆ _method

template<class ResultType , class OwnerType , class StarterType >
Callback Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::_method
private

Definition at line 211 of file ActiveMethod.h.

◆ _pOwner

template<class ResultType , class OwnerType , class StarterType >
OwnerType* Poco::ActiveMethod< ResultType, void, OwnerType, StarterType >::_pOwner
private

Definition at line 210 of file ActiveMethod.h.


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