Releases: vsilaev/tascalate-concurrent
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
CompletableFuture
wrappers inside internal code - useCompletableFuture
class 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
CompletionStage
implementation that implementsFuture
interface as well (i.e. prefer delegation wherever possible) -- seeCompletionStageWrapper
+BlockingCompletionStageAdapter
- Custom
Promise
adapter forCompletionStage
that adds blockingFuture
API (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
AbstractCompletableTask
methodshandle[Async]
andwhenComplete[Async]
now handles exceptions the same way asCompletableFuture
does: 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.anyStrict
andPromises.anyLeast
- Refactored code of
Promises.from
that wraps third-partyCompletionStage
toPromise
- 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
DependentPromise
now is an interfaceConfigurableDependentPromise
is 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 aPromise
that 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:retry
methods are keep executing until no exception is thrown (even if method returnsnull
result),poll
/pollOptional
are 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
Initial release of the library
0.5 Releasing 0.5