Package jadex.bridge
Class SFuture
- java.lang.Object
-
- jadex.bridge.SFuture
-
public class SFuture extends java.lang.Object
Helper class for future aspects.
-
-
Constructor Summary
Constructors Constructor Description SFuture()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
avoidCallTimeouts(Future<?> ret, IExternalAccess ea)
Automatically update the timer of a long running service call future.static void
avoidCallTimeouts(Future<?> ret, IExternalAccess ea, long to, boolean realtime)
Automatically update the timer of a long running service call future.static void
avoidCallTimeouts(Future<?> ret, IExternalAccess ea, long to, double factor, boolean realtime)
Automatically update the timer of a long running service call future.static void
avoidCallTimeouts(Future<?> ret, IInternalAccess ia)
Automatically update the timer of a long running service call future.static void
avoidCallTimeouts(Future<?> ret, IInternalAccess ia, boolean realtime)
Automatically update the timer of a long running service call future.static void
avoidCallTimeouts(Future<?> ret, IInternalAccess ia, long to, boolean realtime)
Automatically update the timer of a long running service call future.static void
avoidCallTimeouts(Future<?> ret, IInternalAccess ia, long to, double factor, boolean realtime)
Automatically update the timer of a long running service call future.static <T,E>
ISubscriptionIntermediateFuture<T>combineSubscriptionFutures(IInternalAccess ia, ISubscriptionIntermediateFuture<E> f1, ISubscriptionIntermediateFuture<E> f2, IResultCommand<T,E> cmd)
Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).static <T> ISubscriptionIntermediateFuture<T>
combineSubscriptionFutures(IInternalAccess ia, ISubscriptionIntermediateFuture<T> f1, ISubscriptionIntermediateFuture<T> f2)
Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).static <T> T
getFirstResultAndTerminate(ITerminableIntermediateFuture<T> fut)
Blocking wait for first result.static <T> Future<?>
getFuture(boolean timeouts, IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).static Future<?>
getFuture(java.lang.Class<?> clazz)
Get the matching future object to a future (interface) type.static <T> Future<?>
getFuture(java.lang.Class<T> type, boolean timeouts, IExternalAccess ea)
Convenience method for creating a future (possibly with timeout avoidance).static <T> Future<?>
getFuture(java.lang.Class<T> type, boolean timeouts, IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).static <T> Future<?>
getNoTimeoutFuture(IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).static <T> Future<?>
getNoTimeoutFuture(java.lang.Class<T> type, IExternalAccess ea)
Convenience method for creating a future (possibly with timeout avoidance).static <T> Future<?>
getNoTimeoutFuture(java.lang.Class<T> type, IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).static <T> Future<?>
getNoTimeoutFuture(java.lang.Class<T> type, IInternalAccess ia, boolean realtime)
Convenience method for creating a future with timeout avoidance.static <T> IntermediateFuture<T>
streamToFuture(IInternalAccess agent, java.util.stream.Stream<T> results)
Create an intermediate future for a stream.
-
-
-
Method Detail
-
streamToFuture
public static <T> IntermediateFuture<T> streamToFuture(IInternalAccess agent, java.util.stream.Stream<T> results)
Create an intermediate future for a stream. The results are pulled from the stream using the agent thread i.e. the agent will be blocked when waiting for stream results. Safe to use (but somewhat useless) for finished streams. Also safe to use for streams, created with IntermediateFuture.asStream(). Not safe to use for other kinds of infinite streams!
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IInternalAccess ia)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that time span. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ia
- The component handling the service call (on that component the periodic updates are scheduled).
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IInternalAccess ia, boolean realtime)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that time span. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ia
- The component handling the service call (on that component the periodic updates are scheduled).realtime
- true, for real time timeouts (simulation clock based timeouts otherwise).
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IExternalAccess ea)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ea
- The component handling the service call (on that component the periodic updates are scheduled).
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IInternalAccess ia, long to, boolean realtime)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ia
- The component handling the service call (on that component the periodic updates are scheduled).to
- The timeout.
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IExternalAccess ea, long to, boolean realtime)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ea
- The component handling the service call (on that component the periodic updates are scheduled).to
- The timeout.
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IInternalAccess ia, long to, double factor, boolean realtime)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ia
- The component handling the service call (on that component the periodic updates are scheduled).to
- The timeout.factor
- (default 0.8) Used to update the timer when factor*to has elapsed.
-
avoidCallTimeouts
public static void avoidCallTimeouts(Future<?> ret, IExternalAccess ea, long to, double factor, boolean realtime)
Automatically update the timer of a long running service call future. Ensures that the caller does not timeout even if no result value is set in that timespan. The call periodically sends alive calls to the caller.- Parameters:
ret
- The future that is returned by the service call.ea
- The component handling the service call (on that component the periodic updates are scheduled).to
- The timeout.factor
- (default 0.8) Used to update the timer when factor*to has elapsed.
-
getNoTimeoutFuture
public static <T> Future<?> getNoTimeoutFuture(IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).- Parameters:
timeouts
- (default is true) False, if no timeouts should be generated when service call timeout has elapsed.ea
- The external access.
-
getNoTimeoutFuture
public static <T> Future<?> getNoTimeoutFuture(java.lang.Class<T> type, IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).- Parameters:
timeouts
- (default is true) False, if no timeouts should be generated when service call timeout has elapsed.ia
- The internal access.
-
getNoTimeoutFuture
public static <T> Future<?> getNoTimeoutFuture(java.lang.Class<T> type, IInternalAccess ia, boolean realtime)
Convenience method for creating a future with timeout avoidance.- Parameters:
type
- The future type (e.g. IntermediateFuture.class).ia
- The internal access.realtime
- true, for real time timeouts (simulation clock based timeouts otherwise).
-
getNoTimeoutFuture
public static <T> Future<?> getNoTimeoutFuture(java.lang.Class<T> type, IExternalAccess ea)
Convenience method for creating a future (possibly with timeout avoidance).- Parameters:
timeouts
- (default is true) False, if no timeouts should be generated when service call timeout has elapsed.ea
- The external access.
-
getFuture
public static <T> Future<?> getFuture(boolean timeouts, IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).- Parameters:
timeouts
- (default is true) False, if no timeouts should be generated when service call timeout has elapsed.ia
- The external access.
-
getFuture
public static <T> Future<?> getFuture(java.lang.Class<T> type, boolean timeouts, IInternalAccess ia)
Convenience method for creating a future (possibly with timeout avoidance).- Parameters:
type
- The future implementation type.timeouts
- (default is true) False, if no timeouts should be generated when service call timeout has elapsed.ia
- The external access.
-
getFuture
public static <T> Future<?> getFuture(java.lang.Class<T> type, boolean timeouts, IExternalAccess ea)
Convenience method for creating a future (possibly with timeout avoidance).- Parameters:
type
- The future implementation type.timeouts
- (default is true) False, if no timeouts should be generated when service call timeout has elapsed.ea
- The external access.
-
getFuture
public static Future<?> getFuture(java.lang.Class<?> clazz)
Get the matching future object to a future (interface) type.
-
getFirstResultAndTerminate
public static <T> T getFirstResultAndTerminate(ITerminableIntermediateFuture<T> fut)
Blocking wait for first result. Future is terminated after first result is received. Defaults to realtime timeout (hack?)- Parameters:
fut
- The future.- Returns:
- The first result.
-
combineSubscriptionFutures
public static <T> ISubscriptionIntermediateFuture<T> combineSubscriptionFutures(IInternalAccess ia, ISubscriptionIntermediateFuture<T> f1, ISubscriptionIntermediateFuture<T> f2)
Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).- Parameters:
f1
- Future 1.f2
- Future 2.- Returns:
- A future combining results of f1 and f2.
-
combineSubscriptionFutures
public static <T,E> ISubscriptionIntermediateFuture<T> combineSubscriptionFutures(IInternalAccess ia, ISubscriptionIntermediateFuture<E> f1, ISubscriptionIntermediateFuture<E> f2, IResultCommand<T,E> cmd)
Combine results of two subscription futures and exclude duplicates (uses sliding cuckoo filter with toString() on results).- Parameters:
f1
- Future 1.f2
- Future 2.- Returns:
- A future combining results of f1 and f2.
-
-