Ark Server API (ASE) - Wiki
|
#include <ActiveMethod.h>
Public Types | |
typedef ResultType(OwnerType::* | Callback) (const ArgType &) |
typedef ActiveResult< ResultType > | ActiveResultType |
typedef ActiveRunnable< ResultType, ArgType, OwnerType > | ActiveRunnableType |
Public Member Functions | |
ActiveMethod (OwnerType *pOwner, Callback method) | |
ActiveResultType | operator() (const ArgType &arg) |
Invokes the ActiveMethod. | |
ActiveMethod (const ActiveMethod &other) | |
ActiveMethod & | operator= (const ActiveMethod &other) |
void | swap (ActiveMethod &other) |
Private Member Functions | |
ActiveMethod () | |
Private Attributes | |
OwnerType * | _pOwner |
Callback | _method |
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, the Void class can be used.
Definition at line 32 of file ActiveMethod.h.
typedef ActiveResult<ResultType> Poco::ActiveMethod< ResultType, ArgType, OwnerType, StarterType >::ActiveResultType |
Definition at line 76 of file ActiveMethod.h.
typedef ActiveRunnable<ResultType, ArgType, OwnerType> Poco::ActiveMethod< ResultType, ArgType, OwnerType, StarterType >::ActiveRunnableType |
Definition at line 77 of file ActiveMethod.h.
typedef ResultType(OwnerType::* Poco::ActiveMethod< ResultType, ArgType, OwnerType, StarterType >::Callback) (const ArgType &) |
Definition at line 75 of file ActiveMethod.h.
|
inline |
Definition at line 79 of file ActiveMethod.h.
|
inline |
Definition at line 96 of file ActiveMethod.h.
|
private |
|
inline |
Invokes the ActiveMethod.
Definition at line 87 of file ActiveMethod.h.
|
inline |
Definition at line 102 of file ActiveMethod.h.
|
inline |
Definition at line 109 of file ActiveMethod.h.
|
private |
Definition at line 119 of file ActiveMethod.h.
|
private |
Definition at line 118 of file ActiveMethod.h.