Poco

template < class RT >

class ActiveResult

Library: Foundation
Package: Threading
Header: Poco/ActiveResult.h

Description

Creates an ActiveResultHolder. Pauses the caller until the result becomes available. Waits up to the specified interval for the result to become available. Returns true if the result became available, false otherwise. Waits up to the specified interval for the result to become available. Throws a TimeoutException if the result did not became available. Notifies the invoking thread that the result became available. Returns true if the active method failed (and threw an exception). Information about the exception can be obtained by calling error(). If the active method threw an exception, a textual representation of the exception is returned. An empty string is returned if the active method completed successfully. If the active method threw an exception, a clone of the exception object is returned, otherwise null. Sets the exception. Sets the exception. This class holds the result of an asynchronous method invocation (see class ActiveMethod). It is used to pass the result from the execution thread back to the invocation thread.

Member Summary

Member Functions: available, data, error, exception, failed, notify, operator =, swap, tryWait, wait

Types

ActiveResultHolderType

typedef ActiveResultHolder < ResultType > ActiveResultHolderType;

ResultType

typedef RT ResultType;

Constructors

ActiveResult inline

ActiveResult(
    ActiveResultHolderType * pHolder
);

Creates the active result. For internal use only.

ActiveResult inline

ActiveResult(
    const ActiveResult & result
);

Copy constructor.

Destructor

~ActiveResult inline

~ActiveResult();

Destroys the result.

Member Functions

available inline

bool available() const;

Returns true if a result is available.

data inline

ResultType & data() const;

Returns a reference to the result data.

data inline

void data(
    ResultType * pValue
);

data inline

ResultType & data();

Returns a non-const reference to the result data. For internal use only.

error inline

std::string error() const;

If the active method threw an exception, a textual representation of the exception is returned. An empty string is returned if the active method completed successfully.

error inline

void error(
    const std::string & msg
);

Sets the failed flag and the exception message.

error inline

void error(
    const Exception & exc
);

Sets the failed flag and the exception message.

exception inline

Exception * exception() const;

If the active method threw an exception, a clone of the exception object is returned, otherwise null.

failed inline

bool failed() const;

Returns true if the active method failed (and threw an exception). Information about the exception can be obtained by calling error().

notify inline

void notify();

Notifies the invoking thread that the result became available. For internal use only.

operator = inline

ActiveResult & operator = (
    const ActiveResult & result
);

Assignment operator.

swap inline

void swap(
    ActiveResult & result
);

tryWait inline

bool tryWait(
    long milliseconds
);

Waits up to the specified interval for the result to become available. Returns true if the result became available, false otherwise.

wait inline

void wait();

Pauses the caller until the result becomes available.

wait inline

void wait(
    long milliseconds
);

Waits up to the specified interval for the result to become available. Throws a TimeoutException if the result did not became available.