Releases: vsilaev/tascalate-concurrent
Extending Promises.all/any/atLeast - widening arguments
Widening generic arguments list type of Promises.all / any / atLeast (both regular and strict variants) to allow passing different implementations of CompletionStage
Bug fixing & Optimizations
- Fix an issue with AbstractCompletableTask.thenComose* -- exceptions in passed functions do not complete resulting stage
- Optimize AbstractCompletableTask.thenComose* to use direct execution of intermediate stage transitions instead of unnecessary calls to Execution.execute.
- ExecutorBoundCompletionStage changes delegation/wrapping sequence (minor)
New Promise API methods; Overriding default async executor; Optimizations + Bug fixes
Bug fixes
The release contains single but very important bug fix - DependentPromise interface now correctly overrides methods inherited from CompletionStage (with DependentPromise as a return type, previously it was Promise)
Optimizations
- Avoid using of
CompletableFuturewrappers inside internal code - useCompletableFutureclass itself - Optimize edge-cases for
Promises.any / anyStrict / atLeast / atLeastStrict - Refactor common code used internally into separate internal utility class to minimize inter-relations between classes.
- Better wrapper for custom
CompletionStageimplementation that implementsFutureinterface as well (i.e. prefer delegation wherever possible) -- seeCompletionStageWrapper+BlockingCompletionStageAdapter - Custom
Promiseadapter forCompletionStagethat adds blockingFutureAPI (previously it was done via implicit creation ofCompletableFuture) -- seeCompletionStageWrapper
Enhancements and new API
The release adds an option to override default async Executor for Promise. Promise.defaultAsyncOn(Executor) + related adapters serves this purpose. Also, DependentPromise extend this behavior for own declared methods (the ones these let user enlist origins).
Additionally. Promise.join() method is added - technically, it's like a Promise.get() but without throwing checked exceptions.
Bug fixing & Refactoring
The release contains minor bug-fixing and refactorings
AbstractCompletableTaskmethodshandle[Async]andwhenComplete[Async]now handles exceptions the same way asCompletableFuturedoes: any exception inwhenComplete[Async]does not override original exception for subsequent stages (though, it's enlisted in addSuppressed); exceptions are wrapped intoCompletionException- Optimize edge-cases for
Promises.any,Promises.anyStrictandPromises.anyLeast - Refactored code of
Promises.fromthat wraps third-partyCompletionStagetoPromise - Fixed rounding error with
DurationCalcs.safeExtractAmount
Fixing edge-case overflows when working with Duration
Since version 0.6.0 the library uses smallest possible time precision (NANOS) for delays and timeouts.
In edge cases overflow was possible when library converts/re-calculates durations with NANOS precision.
This release mainly address this issue.
Internal Refactoring & Bug Fixing
Features
DependentPromise changes
DependentPromisenow is an interfaceConfigurableDependentPromiseis an implementation ofDependentPromise-- it provides support for both explicit (available previously) and implicit (new functionality) enlistment of origins
Promise changes
Promise.dependent(implicitlyEnlistDependency)is added to let create a variant of promise that implicitly enlists dependency (previously only explicit enlistments via additional argument was possible)Promise.raw()method is added to return aPromisethat is free from any behavior decorators (likeConfigurableDependentPromise)
Helper classes
- Adapters and decorators hierarchy has been revisited to provide classes that simplifies implementation of custom decorators / adapters
Re-tryable polling support
Promises.poll(runnable, executor, retryPolicy)is renamed toPromises.retry(runnable, executor, retryPolicy)Promises.poll(callable, executor, retryPolicy)is complemented byPromises.retry(callable, executor, retryPolicy)
The naming now reflects the purpose:retrymethods are keep executing until no exception is thrown (even if method returnsnullresult),poll/pollOptionalare executed unless result (non-null or non-emptyOptional) is returned.
Bug fixes
Minor bug fixing for timeout-related methods (in some places boolean constants was used instead of method-supplied arguments)
Polling & Timeout-related functionality
Features
Promise interface is extended with timeout-related methods
Promise.onTimeout(delay, [cancelOnTimeout=true])Promise.orTimeout(defaultValue, delay, [cancelOnTimeout=true)Promise.delay(delay, [delayOnError=true])
Additionally, there is a method to specify initial delayCompletableTask.delay(delay, executor)
Re-tryable polling support
Promises now extended with several methods that allows polling Runnable / Callable according to RetryPolicy until result is available:
Promises.poll(runnable, executor, retryPolicy)Promises.poll(callable, executor, retryPolicy)Promises.pollOptional(callableWithOptionalResult executor, retryPolicy)
Easing creation of DependentPromise
Promise now have a dependent() method that converts this Promise to a DependentPromise to allow writing of fluent API chains.
Promises combinators methods now have additional overloads
Promises.all / any / atLeast and corresponding *Strict now overloaded to accept a list of Promise-es in addition to vararg array.
Bug fixes
None
DependentPromise - support for cancellation of Promise origins
Feature: this release introduces new class DependentPromise - a wrapper that may keep track of CompletionStage-s it's originated from. Also, this wrapper will cancel all the origins enlisted.
Feature: additionally, Promises class adds several overload to all, any, atLeast and corresponding *Strict variants to let specify whether or not CompletionStage-s should be cancelled.
Bug fix: AbstractCompletableTask.thenComposeAsync now correctly cancels all intermediate (hidden from client) Promise-s used.
Adding supplyAsync / runAsync as CompletableTask API entry points
0.5.2 Update README.md
Bug-fixing and minor extensions
- Fixed an issues with AbstractCompletableTask.whenCompleteAsync(...) -- wrong executor where used in constructor.
- Adding Promise.getNow(...) methods