...
Scrollbar |
---|
...
The ParallelExecutor service allows a computation to occur in parallel.
It can be used in two ways. First, with an explicit Future:
Code Block | ||||
---|---|---|---|---|
| ||||
Future<String> future = executor.invoke(new Invokable<String>() { ... }); |
...
The ultimate value of the Invokable is available from by invoking get()
on the Future; this will block until the value is ready.
...
Another alternative will return an object proxy, not a Future:
Code Block | ||||
---|---|---|---|---|
| ||||
RSSFeed feed = executor.invoke(RSSFeed.class, new Invokable<RSSFeed>() { ... }); |
This only works if the type is an interface. A proxy for the interface is created around the Future object; any invocation on the proxy will invoke get() on the Future (that is, will block until the value is computed).
Configuration
The behavior of the ParallelExecutor can be tuned with global configuration symbols.
Java constants for the configuration Configuraton symbols are defined in IOCSymbols.
tapestry.thread-pool-enabled
If " true", the default, then the thread pool will operate. If " false", then ParallelExecutor's implementation changes to invoke the Invokable immediately, not in a pooled thread. This is useful in environments, such as Google App Engine, that do not support the creation of threads and thread pools.
tapestry.thread-pool.core-pool-size
Minimum size of the thread pool. Defaults to 3.
tapestry.thread-pool.max-pool-size
Maximum number of threads (active or inactive) in the thread pool. Defaults to 20.
tapestry.thread-pool.keep-alive
Time to keep waiting threads alive. Defaults to "1 m" (one minute).
...
tapestry.thread-pool.queue-size
Since | ||
---|---|---|
| ||
Defaults to 100.
Scrollbar |
---|