You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2011/07/15 23:38:51 UTC
svn commit: r1147324 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent:
Callable.h Future.h
Author: tabish
Date: Fri Jul 15 21:38:51 2011
New Revision: 1147324
URL: http://svn.apache.org/viewvc?rev=1147324&view=rev
Log:
Add a non-templated marker interface so that non-template code can determine if a particular Runnable is a Future or Callable type and needs special processing.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Callable.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Future.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Callable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Callable.h?rev=1147324&r1=1147323&r2=1147324&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Callable.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Callable.h Fri Jul 15 21:38:51 2011
@@ -26,6 +26,15 @@ namespace util {
namespace concurrent {
/**
+ * Base class of all Callable<T> objects, used to allow identification via type casting.
+ */
+ class CallableType {
+ public:
+
+ virtual ~CallableType() {}
+ };
+
+ /**
* A task that returns a result and may throw an exception. Implementors define a single method with no
* arguments called call. This interface differs from the Runnable interface in that a Callable object
* can return a result and is allowed to throw an exceptions from its call method.
@@ -35,7 +44,7 @@ namespace concurrent {
* @since 1.0
*/
template<typename V>
- class DECAF_API Callable {
+ class Callable : public CallableType {
public:
virtual ~Callable() {}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Future.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Future.h?rev=1147324&r1=1147323&r2=1147324&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Future.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Future.h Fri Jul 15 21:38:51 2011
@@ -18,30 +18,18 @@
#ifndef _DECAF_UTIL_CONCURRENT_FUTURE_H_
#define _DECAF_UTIL_CONCURRENT_FUTURE_H_
+#include <decaf/util/Config.h>
+
#include <decaf/util/concurrent/TimeUnit.h>
namespace decaf {
namespace util {
namespace concurrent {
- /**
- * A Future represents the result of an asynchronous computation. Methods
- * are provided to check if the computation is complete, to wait for its
- * completion, and to retrieve the result of the computation. The result
- * can only be retrieved using method get when the computation has
- * completed, blocking if necessary until it is ready. Cancellation is
- * performed by the cancel method. Additional methods are provided to
- * determine if the task completed normally or was canceled. Once a
- * computation has completed, the computation cannot be canceled. If you
- * would like to use a Future for the sake of cancellability but not
- * provide a usable result, you can declare types of the form Future<void*>
- * and return null as a result of the underlying task.
- */
- template<typename V>
- class Future {
+ class FutureType {
public:
- virtual ~Future() {}
+ virtual ~FutureType() {}
/**
* Attempts to cancel execution of this task. This attempt will fail if the
@@ -51,15 +39,17 @@ namespace concurrent {
* has already started, then the mayInterruptIfRunning parameter determines
* whether the thread executing this task should be interrupted in an attempt
* to stop the task.
- * <p>
+ *
* After this method returns, subsequent calls to isDone() will always return
* true. Subsequent calls to isCancelled() will always return true if this
* method returned true.
- * <p>
- * @param mayInterruptIfRunning - true if the thread executing this task should
- * be interrupted; otherwise, in-progress tasks are allowed to complete.
+ *
+ * @param mayInterruptIfRunning
+ * True if the thread executing this task should be interrupted; otherwise,
+ * in-progress tasks are allowed to complete.
+ *
* @returns false if the task could not be canceled, typically because it has
- * already completed normally; true otherwise
+ * already completed normally; true otherwise
*/
virtual bool cancel( bool mayInterruptIfRunning ) = 0;
@@ -77,6 +67,29 @@ namespace concurrent {
*/
virtual bool isDone() const = 0;
+ };
+
+ /**
+ * A Future represents the result of an asynchronous computation. Methods
+ * are provided to check if the computation is complete, to wait for its
+ * completion, and to retrieve the result of the computation. The result
+ * can only be retrieved using method get when the computation has
+ * completed, blocking if necessary until it is ready. Cancellation is
+ * performed by the cancel method. Additional methods are provided to
+ * determine if the task completed normally or was canceled. Once a
+ * computation has completed, the computation cannot be canceled. If you
+ * would like to use a Future for the sake of cancellability but not
+ * provide a usable result, you can declare types of the form Future<void*>
+ * and return null as a result of the underlying task.
+ *
+ * @since 1.0
+ */
+ template<typename V>
+ class Future : public FutureType {
+ public:
+
+ virtual ~Future() {}
+
/**
* Waits if necessary for the computation to complete, and then retrieves its result.
* @returns the computed result.