bookkeeper-distributedlog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leighst <...@git.apache.org>
Subject [GitHub] incubator-distributedlog pull request #133: DL-124: Use Java8 Future rather ...
Date Fri, 09 Jun 2017 04:19:40 GMT
Github user leighst commented on a diff in the pull request:

    https://github.com/apache/incubator-distributedlog/pull/133#discussion_r121046188
  
    --- Diff: distributedlog-core/src/main/java/org/apache/distributedlog/BKLogReadHandler.java
---
    @@ -201,33 +183,31 @@ public void safeRun() {
          * Begin asynchronous lock acquire, but ensure that the returned future is satisfied
on an
          * executor service thread.
          */
    -    Future<Void> acquireLockOnExecutorThread(DistributedLock lock) throws LockingException
{
    -        final Future<? extends DistributedLock> acquireFuture = lock.asyncAcquire();
    +    CompletableFuture<Void> acquireLockOnExecutorThread(DistributedLock lock) throws
LockingException {
    +        final CompletableFuture<? extends DistributedLock> acquireFuture = lock.asyncAcquire();
     
             // The future we return must be satisfied on an executor service thread. If we
simply
             // return the future returned by asyncAcquire, user callbacks may end up running
in
             // the lock state executor thread, which will cause deadlocks and introduce latency
             // etc.
    -        final Promise<Void> threadAcquirePromise = new Promise<Void>();
    -        threadAcquirePromise.setInterruptHandler(new Function<Throwable, BoxedUnit>()
{
    -            @Override
    -            public BoxedUnit apply(Throwable t) {
    -                FutureUtils.cancel(acquireFuture);
    -                return null;
    +        final CompletableFuture<Void> threadAcquirePromise = new CompletableFuture<Void>();
    +        threadAcquirePromise.whenComplete((value, cause) -> {
    --- End diff --
    
    do i understand correctly java8 future doesn't really have the concept of interrupt?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message