distributedlog-dev mailing list archives

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

    --- 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
             // return the future returned by asyncAcquire, user callbacks may end up running
             // 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 --
    correctly, java8 future doesn't have the concept of interrupt. I try to simulate the similar

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.

View raw message